| 1: |
| 2: |
| 3: |
| 4: |
| 5: |
| 6: |
| 7: |
| 8: |
| 9: |
| 10: |
| 11: |
| 12: |
| 13: |
| 14: |
| 15: |
| 16: |
| 17: |
| 18: |
| 19: |
| 20: |
| 21: |
| 22: |
| 23: |
| 24: |
| 25: |
| 26: |
| 27: |
| 28: |
| 29: |
| 30: |
| 31: |
| 32: |
| 33: # include "gtest/gtest.h" |
| 34: # include "gtest/internal/custom/gtest.h" |
| 35: # include "gtest/gtest-spi.h" |
| 36: |
| 37: # include < ctype . h > |
| 38: # include < stdarg . h > |
| 39: # include < stdio . h > |
| 40: # include < stdlib . h > |
| 41: # include < time . h > |
| 42: # include < wchar . h > |
| 43: # include < wctype . h > |
| 44: |
| 45: # include < algorithm > |
| 46: # include < chrono > |
| 47: # include < cmath > |
| 48: # include < cstdint > |
| 49: # include < iomanip > |
| 50: # include < limits > |
| 51: # include < list > |
| 52: # include < map > |
| 53: # include < ostream > |
| 54: # include < sstream > |
| 55: # include < vector > |
| 56: |
| 57: # if GTEST_OS_LINUX |
| 58: |
| 59: # include < fcntl . h > |
| 60: # include < limits . h > |
| 61: # include < sched . h > |
| 62: |
| 63: # include < strings . h > |
| 64: # include < sys / mman . h > |
| 65: # include < sys / time . h > |
| 66: # include < unistd . h > |
| 67: # include < string > |
| 68: |
| 69: # elif GTEST_OS_ZOS |
| 70: # include < sys / time . h > |
| 71: |
| 72: |
| 73: # include < strings . h > |
| 74: |
| 75: # elif GTEST_OS_WINDOWS_MOBILE |
| 76: |
| 77: # include < windows . h > |
| 78: # undef min |
| 79: |
| 80: # elif GTEST_OS_WINDOWS |
| 81: |
| 82: # include < windows . h > |
| 83: # undef min |
| 84: |
| 85: # ifdef _MSC_VER |
| 86: # include < crtdbg . h > |
| 87: # endif |
| 88: |
| 89: # include < io . h > |
| 90: # include < sys / timeb . h > |
| 91: # include < sys / types . h > |
| 92: # include < sys / stat . h > |
| 93: |
| 94: # if GTEST_OS_WINDOWS_MINGW |
| 95: # include < sys / time . h > |
| 96: # endif |
| 97: |
| 98: # else |
| 99: |
| 100: |
| 101: |
| 102: # include < sys / time . h > |
| 103: # include < unistd . h > |
| 104: |
| 105: # endif |
| 106: |
| 107: # if GTEST_HAS_EXCEPTIONS |
| 108: # include < stdexcept > |
| 109: # endif |
| 110: |
| 111: # if GTEST_CAN_STREAM_RESULTS_ |
| 112: # include < arpa / inet . h > |
| 113: # include < netdb . h > |
| 114: # include < sys / socket . h > |
| 115: # include < sys / types . h > |
| 116: # endif |
| 117: |
| 118: # include "src/gtest-internal-inl.h" |
| 119: |
| 120: # if GTEST_OS_WINDOWS |
| 121: # define vsnprintf _vsnprintf |
| 122: # endif |
| 123: |
| 124: # if GTEST_OS_MAC |
| 125: # ifndef GTEST_OS_IOS |
| 126: # include < crt_externs . h > |
| 127: # endif |
| 128: # endif |
| 129: |
| 130: # if GTEST_HAS_ABSL |
| 131: # include "absl/debugging/failure_signal_handler.h" |
| 132: # include "absl/debugging/stacktrace.h" |
| 133: # include "absl/debugging/symbolize.h" |
| 134: # include "absl/strings/str_cat.h" |
| 135: # endif |
| 136: |
| 137: namespace testing { |
| 138: |
| 139: using internal :: CountIf ; |
| 140: using internal :: ForEach ; |
| 141: using internal :: GetElementOr ; |
| 142: using internal :: Shuffle ; |
| 143: |
| 144: |
| 145: |
| 146: |
| 147: |
| 148: static const char kDisableTestFilter [ ] = "DISABLED_*:*/DISABLED_*" ; |
| 149: |
| 150: |
| 151: |
| 152: |
| 153: static const char kDeathTestSuiteFilter [ ] = "*DeathTest:*DeathTest/*" ; |
| 154: |
| 155: |
| 156: static const char kUniversalFilter [ ] = "*" ; |
| 157: |
| 158: |
| 159: static const char kDefaultOutputFormat [ ] = "xml" ; |
| 160: |
| 161: static const char kDefaultOutputFile [ ] = "test_detail" ; |
| 162: |
| 163: |
| 164: static const char kTestShardIndex [ ] = "GTEST_SHARD_INDEX" ; |
| 165: |
| 166: static const char kTestTotalShards [ ] = "GTEST_TOTAL_SHARDS" ; |
| 167: |
| 168: static const char kTestShardStatusFile [ ] = "GTEST_SHARD_STATUS_FILE" ; |
| 169: |
| 170: namespace internal { |
| 171: |
| 172: |
| 173: |
| 174: const char kStackTraceMarker [ ] = "\nStack trace:\n" ; |
| 175: |
| 176: |
| 177: |
| 178: bool g_help_flag = false ; |
| 179: |
| 180: |
| 181: static FILE * OpenFileForWriting ( const std :: string & output_file ) { |
| 182: FILE * fileout = nullptr ; |
| 183: FilePath output_file_path ( output_file ) ; |
| 184: FilePath output_dir ( output_file_path . RemoveFileName ( ) ) ; |
| 185: |
186: if/* if (output_dir.CreateDirectoriesRecursively()) {
fileout = posix::FOpen(output_file.c_str(), "w");
} */ output_dir . CreateDirectoriesRecursively ( ) ) {/*
fileout = posix::FOpen(output_file.c_str(), "w");
*/ |
187: fileout/* fileout = posix::FOpen(output_file.c_str(), "w") */ = posix :: FOpen ( output_file . c_str ( ) , "w" ) ; |
| 188: } |
189: if/* if (fileout == nullptr) {
GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file << "\"";
} */ fileout == nullptr ) {/*
GTEST_LOG_(FATAL) << "Unable to open file \"" << output_file << "\"";
*/ |
| 190: GTEST_LOG_ ( FATAL ) << "Unable to open file \"" << output_file << "\"" ; |
| 191: } |
| 192: return fileout ; |
| 193: } |
| 194: |
| 195: } |
| 196: |
| 197: |
| 198: |
| 199: static const char * GetDefaultFilter ( ) { |
| 200: const char * const testbridge_test_only = |
| 201: internal :: posix :: GetEnv ( "TESTBRIDGE_TEST_ONLY" ) ; |
| 202: if testbridge_test_only != nullptr ) { |
| 203: return testbridge_test_only ; |
| 204: } |
| 205: return kUniversalFilter ; |
| 206: } |
| 207: |
| 208: |
| 209: |
| 210: static bool GetDefaultFailFast ( ) { |
| 211: const char * const testbridge_test_runner_fail_fast = |
| 212: internal :: posix :: GetEnv ( "TESTBRIDGE_TEST_RUNNER_FAIL_FAST" ) ; |
| 213: if testbridge_test_runner_fail_fast != nullptr ) { |
| 214: return ( testbridge_test_runner_fail_fast , "1" ) == 0 ; |
| 215: } |
| 216: return ; |
| 217: } |
| 218: |
| 219: GTEST_DEFINE_bool_ ( |
| 220: fail_fast , internal :: BoolFromGTestEnv ( "fail_fast" , GetDefaultFailFast ( ) ) , |
| 221: "True if and only if a test failure should stop further test execution." ) ; |
| 222: |
| 223: GTEST_DEFINE_bool_ ( |
| 224: also_run_disabled_tests , |
| 225: internal :: BoolFromGTestEnv ( "also_run_disabled_tests" , false ) , |
| 226: "Run disabled tests too, in addition to the tests normally being run." ) ; |
| 227: |
| 228: GTEST_DEFINE_bool_ ( |
| 229: break_on_failure , internal :: BoolFromGTestEnv ( "break_on_failure" , false ) , |
| 230: "True if and only if a failed assertion should be a debugger " |
| 231: "break-point." ) ; |
| 232: |
| 233: GTEST_DEFINE_bool_ ( catch_exceptions , |
| 234: internal :: BoolFromGTestEnv ( "catch_exceptions" , true ) , |
| 235: "True if and only if " GTEST_NAME_ |
| 236: " should catch exceptions and treat them as test failures." ) ; |
| 237: |
| 238: GTEST_DEFINE_string_ ( |
| 239: color , |
| 240: internal :: StringFromGTestEnv ( "color" , "auto" ) , |
| 241: "Whether to use colors in the output. Valid values: yes, no, " |
| 242: "and auto. 'auto' means to use colors if the output is " |
| 243: "being sent to a terminal and the TERM environment variable " |
| 244: "is set to a terminal type that supports colors." ) ; |
| 245: |
| 246: GTEST_DEFINE_string_ ( |
| 247: filter , |
| 248: internal :: StringFromGTestEnv ( "filter" , GetDefaultFilter ( ) ) , |
| 249: "A colon-separated list of glob (not regex) patterns " |
| 250: "for filtering the tests to run, optionally followed by a " |
| 251: "'-' and a : separated list of negative patterns (tests to " |
| 252: "exclude). A test is run if it matches one of the positive " |
| 253: "patterns and does not match any of the negative patterns." ) ; |
| 254: |
| 255: GTEST_DEFINE_bool_ ( |
| 256: install_failure_signal_handler , |
| 257: internal :: BoolFromGTestEnv ( "install_failure_signal_handler" , false ) , |
| 258: "If true and supported on the current platform, " GTEST_NAME_ " should " |
| 259: "install a signal handler that dumps debugging information when fatal " |
| 260: "signals are raised." ) ; |
| 261: |
| 262: GTEST_DEFINE_bool_ ( list_tests , false , |
| 263: "List all tests without running them." ) ; |
| 264: |
| 265: |
| 266: |
| 267: |
| 268: |
| 269: |
| 270: GTEST_DEFINE_string_ ( |
| 271: output , |
| 272: internal :: StringFromGTestEnv ( "output" , |
| 273: internal :: OutputFlagAlsoCheckEnvVar ( ) . c_str ( ) ) , |
| 274: "A format (defaults to \"xml\" but can be specified to be \"json\"), " |
| 275: "optionally followed by a colon and an output file name or directory. " |
| 276: "A directory is indicated by a trailing pathname separator. " |
| 277: "Examples: \"xml:filename.xml\", \"xml::directoryname/\". " |
| 278: "If a directory is specified, output files will be created " |
| 279: "within that directory, with file-names based on the test " |
| 280: "executable's name and, if necessary, made unique by adding " |
| 281: "digits." ) ; |
| 282: |
| 283: GTEST_DEFINE_bool_ ( |
| 284: brief , internal :: BoolFromGTestEnv ( "brief" , false ) , |
| 285: "True if only test failures should be displayed in text output." ) ; |
| 286: |
| 287: GTEST_DEFINE_bool_ ( print_time , internal :: BoolFromGTestEnv ( "print_time" , true ) , |
| 288: "True if and only if " GTEST_NAME_ |
| 289: " should display elapsed time in text output." ) ; |
| 290: |
| 291: GTEST_DEFINE_bool_ ( print_utf8 , internal :: BoolFromGTestEnv ( "print_utf8" , true ) , |
| 292: "True if and only if " GTEST_NAME_ |
| 293: " prints UTF8 characters as text." ) ; |
| 294: |
| 295: GTEST_DEFINE_int32_ ( |
| 296: random_seed , |
| 297: internal :: Int32FromGTestEnv ( "random_seed" , 0 ) , |
| 298: "Random number seed to use when shuffling test orders. Must be in range " |
| 299: "[1, 99999], or 0 to use a seed based on the current time." ) ; |
| 300: |
| 301: GTEST_DEFINE_int32_ ( |
| 302: repeat , |
| 303: internal :: Int32FromGTestEnv ( "repeat" , 1 ) , |
| 304: "How many times to repeat each test. Specify a negative number " |
| 305: "for repeating forever. Useful for shaking out flaky tests." ) ; |
| 306: |
| 307: GTEST_DEFINE_bool_ ( show_internal_stack_frames , false , |
| 308: "True if and only if " GTEST_NAME_ |
| 309: " should include internal stack frames when " |
| 310: "printing test failure stack traces." ) ; |
| 311: |
| 312: GTEST_DEFINE_bool_ ( shuffle , internal :: BoolFromGTestEnv ( "shuffle" , false ) , |
| 313: "True if and only if " GTEST_NAME_ |
| 314: " should randomize tests' order on every run." ) ; |
| 315: |
| 316: GTEST_DEFINE_int32_ ( |
| 317: stack_trace_depth , |
| 318: internal :: Int32FromGTestEnv ( "stack_trace_depth" , kMaxStackTraceDepth ) , |
| 319: "The maximum number of stack frames to print when an " |
| 320: "assertion fails. The valid range is 0 through 100, inclusive." ) ; |
| 321: |
| 322: GTEST_DEFINE_string_ ( |
| 323: stream_result_to , |
| 324: internal :: StringFromGTestEnv ( "stream_result_to" , "" ) , |
| 325: "This flag specifies the host name and the port number on which to stream " |
| 326: "test results. Example: \"localhost:555\". The flag is effective only on " |
| 327: "Linux." ) ; |
| 328: |
| 329: GTEST_DEFINE_bool_ ( |
| 330: throw_on_failure , |
| 331: internal :: BoolFromGTestEnv ( "throw_on_failure" , false ) , |
| 332: "When this flag is specified, a failed assertion will throw an exception " |
| 333: "if exceptions are enabled or exit the program with a non-zero code " |
| 334: "otherwise. For use with an external test framework." ) ; |
| 335: |
| 336: # if GTEST_USE_OWN_FLAGFILE_FLAG_ |
| 337: GTEST_DEFINE_string_ ( |
| 338: flagfile , |
| 339: internal :: StringFromGTestEnv ( "flagfile" , "" ) , |
| 340: "This flag specifies the flagfile to read command-line flags from." ) ; |
| 341: # endif |
| 342: |
| 343: namespace internal { |
| 344: |
| 345: |
| 346: |
| 347: |
| 348: uint32_t Random :: Generate ( uint32_t range ) { |
| 349: |
| 350: |
351: state_/* state_ = static_cast<uint32_t>(1103515245ULL*state_ + 12345U) % kMaxRange */ = static_cast < uint32_t > ( 1103515245ULL * state_ + 12345U ) % kMaxRange ; |
| 352: |
| 353: GTEST_CHECK_ ( range > 0 ) |
| 354: << "Cannot generate a number in the range [0, 0)." ; |
| 355: GTEST_CHECK_ ( range <= kMaxRange ) |
| 356: << "Generation of a number in [0, " << range << ") was requested, " |
| 357: << "but this can only generate numbers in [0, " << kMaxRange << ")." ; |
| 358: |
| 359: |
| 360: |
| 361: |
| 362: return state_ % range ; |
| 363: } |
| 364: |
| 365: |
| 366: |
| 367: |
| 368: static bool GTestIsInitialized ( ) { return ( ) . size ( ) > 0 ; } |
| 369: |
| 370: |
| 371: |
| 372: |
| 373: static int SumOverTestSuiteList ( const std :: vector < TestSuite * > & case_list , |
| 374: int ( TestSuite :: * method ) ( ) const ) { |
| 375: int sum = 0 ; |
376: for/* for (size_t i = 0; i < case_list.size(); i++) {
sum += (case_list[i]->*method)();
} */ ( size_t i = 0 ; i < case_list . size ( ) ; i ++ ) {/*
sum += (case_list[i]->*method)();
*/ |
377: sum/* sum += (case_list[i]->*method)() */ += ( case_list [ i ] ->* method ) ( ) ; |
| 378: } |
| 379: return sum ; |
| 380: } |
| 381: |
| 382: |
| 383: static bool TestSuitePassed ( const TestSuite * test_suite ) { |
| 384: return test_suitetruefalsetruefalse -> should_run ( ) test_suite -> Passed ( ) ; |
| 385: } |
| 386: |
| 387: |
| 388: static bool TestSuiteFailed ( const TestSuite * test_suite ) { |
| 389: return test_suitetruefalsetruefalse -> should_run ( ) test_suite -> Failed ( ) ; |
| 390: } |
| 391: |
| 392: |
| 393: |
| 394: static bool ShouldRunTestSuite ( const TestSuite * test_suite ) { |
| 395: return -> should_run ( ) ; |
| 396: } |
| 397: |
| 398: |
| 399: AssertHelper :: AssertHelper ( TestPartResult :: Type type , |
| 400: const char * file , |
| 401: int line , |
| 402: const char * message ) |
| 403: : data_ ( new AssertHelperData ( type , file , line , message ) ) { |
| 404: } |
| 405: |
| 406: AssertHelper :: ~ AssertHelper ( ) |
| 407: delete data_ ; |
| 408: } |
| 409: |
| 410: |
| 411: void AssertHelper :: operator = ( const Message & message ) const {/*
UnitTest::GetInstance()->
AddTestPartResult(data_->type, data_->file, data_->line,
AppendUserMessage(data_->message, message),
UnitTest::GetInstance()->impl()
->CurrentOsStackTraceExceptTop(1)
// Skips the stack frame for this function itself.
); // NOLINT
*/ |
| 412: UnitTest :: GetInstance ( ) -> |
| 413: AddTestPartResult ( data_ -> type , data_ -> file , data_ -> line , |
| 414: AppendUserMessage ( data_ -> message , message ) , |
| 415: UnitTest :: GetInstance ( ) -> impl ( ) |
| 416: -> CurrentOsStackTraceExceptTop ( 1 ) |
| 417: |
| 418: ) ; |
| 419: } |
| 420: |
| 421: namespace { |
| 422: |
| 423: |
| 424: |
| 425: |
| 426: |
| 427: |
| 428: constexpr bool kErrorOnUninstantiatedParameterizedTest = true ; |
| 429: constexpr bool kErrorOnUninstantiatedTypeParameterizedTest = true ; |
| 430: |
| 431: |
| 432: class FailureTest : public Test { |
| 433: public : |
| 434: explicit FailureTest ( const CodeLocation & loc , std :: string error_message , |
| 435: bool as_error ) |
| 436: : loc_ ( loc ) , |
| 437: error_message_ ( std :: move ( error_message ) ) , |
| 438: as_error_ ( as_error ) { } |
| 439: |
| 440: void TestBody ( ) override {/*
if (as_error_) {
AssertHelper(TestPartResult::kNonFatalFailure, loc_.file.c_str(),
loc_.line, "") = Message() << error_message_;
} else {
std::cout << error_message_ << std::endl;
}
*/ |
441: if/* if (as_error_) {
AssertHelper(TestPartResult::kNonFatalFailure, loc_.file.c_str(),
loc_.line, "") = Message() << error_message_;
} else {
std::cout << error_message_ << std::endl;
} */ as_error_ ) {/*
AssertHelper(TestPartResult::kNonFatalFailure, loc_.file.c_str(),
loc_.line, "") = Message() << error_message_;
*/ |
| 442: AssertHelper ( TestPartResult :: kNonFatalFailure , loc_ . file . c_str ( ) , |
| 443: loc_ . line , "" ) = Message ( ) << error_message_ ; |
| 444: } else {/*
std::cout << error_message_ << std::endl;
*/ |
445: std/* std::cout << error_message_ << std::endl */ :: cout << error_message_ << std :: endl ; |
| 446: } |
| 447: } |
| 448: |
| 449: private : |
| 450: const CodeLocation loc_ ; |
| 451: const std :: string error_message_ ; |
| 452: const bool as_error_ ; |
| 453: } ; |
| 454: |
| 455: |
| 456: } |
| 457: |
| 458: std :: set < std :: string > * GetIgnoredParameterizedTestSuites ( ) { |
| 459: return UnitTest :: GetInstance ( ) -> impl ( ) -> ignored_parameterized_test_suites ( ) ; |
| 460: } |
| 461: |
| 462: |
| 463: MarkAsIgnored :: MarkAsIgnored ( const char * test_suite ) {/*
GetIgnoredParameterizedTestSuites()->insert(test_suite);
*/ |
| 464: GetIgnoredParameterizedTestSuites ( ) -> insert ( test_suite ) ; |
| 465: } |
| 466: |
| 467: |
| 468: |
| 469: void InsertSyntheticTestCase ( const std :: string & name , CodeLocation location , |
| 470: bool has_test_p ) { |
| 471: const auto & ignored = * GetIgnoredParameterizedTestSuites ( ) ; |
472: if/* if (ignored.find(name) != ignored.end()) return */ ignored . find ( name ) != ignored . end ( ) ) ; |
| 473: |
| 474: const char kMissingInstantiation [ ] = |
| 475: " is defined via TEST_P, but never instantiated. None of the test cases " |
| 476: "will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the only " |
| 477: "ones provided expand to nothing." |
| 478: "\n\n" |
| 479: "Ideally, TEST_P definitions should only ever be included as part of " |
| 480: "binaries that intend to use them. (As opposed to, for example, being " |
| 481: "placed in a library that may be linked in to get other utilities.)" ; |
| 482: |
| 483: const char kMissingTestCase [ ] = |
| 484: " is instantiated via INSTANTIATE_TEST_SUITE_P, but no tests are " |
| 485: "defined via TEST_P . No test cases will run." |
| 486: "\n\n" |
| 487: "Ideally, INSTANTIATE_TEST_SUITE_P should only ever be invoked from " |
| 488: "code that always depend on code that provides TEST_P. Failing to do " |
| 489: "so is often an indication of dead code, e.g. the last TEST_P was " |
| 490: "removed but the rest got left behind." ; |
| 491: |
| 492: std :: string message = |
| 493: "Parameterized test suite " + name + |
| 494: ( has_test_p ? kMissingInstantiation : kMissingTestCase ) + |
| 495: "\n\n" |
| 496: "To suppress this error for this test suite, insert the following line " |
| 497: "(in a non-header) in the namespace it is defined in:" |
| 498: "\n\n" |
| 499: "GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(" + name + ");" ; |
| 500: |
| 501: std :: string full_name = "UninstantiatedParameterizedTestSuite<" + name + ">" ; |
| 502: RegisterTest ( |
| 503: "GoogleTestVerification" , full_name . c_str ( ) , |
| 504: nullptr , |
| 505: nullptr , |
| 506: location . file . c_str ( ) , location . line , [ message , location ] { |
| 507: return new FailureTest ( location , message , |
| 508: kErrorOnUninstantiatedParameterizedTest ) ; |
| 509: } ) ; |
| 510: } |
| 511: |
| 512: void RegisterTypeParameterizedTestSuite ( const char * test_suite_name , |
| 513: CodeLocation code_location ) {/*
GetUnitTestImpl()->type_parameterized_test_registry().RegisterTestSuite(
test_suite_name, code_location);
*/ |
| 514: GetUnitTestImpl ( ) -> type_parameterized_test_registry ( ) . RegisterTestSuite ( |
| 515: test_suite_name , code_location ) ; |
| 516: } |
| 517: |
| 518: void RegisterTypeParameterizedTestSuiteInstantiation ( const char * case_name ) {/*
GetUnitTestImpl()
->type_parameterized_test_registry()
.RegisterInstantiation(case_name);
*/ |
519: GetUnitTestImpl/* GetUnitTestImpl()
->type_parameterized_test_registry()
.RegisterInstantiation(case_name) */ ( ) |
| 520: -> type_parameterized_test_registry ( ) |
| 521: . RegisterInstantiation ( case_name ) ; |
| 522: } |
| 523: |
| 524: void TypeParameterizedTestSuiteRegistry :: RegisterTestSuite ( |
| 525: const char * test_suite_name , CodeLocation code_location ) {/*
suites_.emplace(std::string(test_suite_name),
TypeParameterizedTestSuiteInfo(code_location));
*/ |
| 526: suites_ . emplace ( std :: string ( test_suite_name ) , |
| 527: TypeParameterizedTestSuiteInfo ( code_location ) ) ; |
| 528: } |
| 529: |
| 530: void TypeParameterizedTestSuiteRegistry :: RegisterInstantiation ( |
| 531: const char * test_suite_name ) {/*
auto it = suites_.find(std::string(test_suite_name));
if (it != suites_.end()) {
it->second.instantiated = true;
} else {
GTEST_LOG_(ERROR) << "Unknown type parameterized test suit '"
<< test_suite_name << "'";
}
*/ |
| 532: auto it = suites_ . find ( std :: string ( test_suite_name ) ) ; |
533: if/* if (it != suites_.end()) {
it->second.instantiated = true;
} else {
GTEST_LOG_(ERROR) << "Unknown type parameterized test suit '"
<< test_suite_name << "'";
} */ it != suites_ . end ( ) ) {/*
it->second.instantiated = true;
*/ |
534: it/* it->second.instantiated = true */ -> second . instantiated = true ; |
| 535: } else {/*
GTEST_LOG_(ERROR) << "Unknown type parameterized test suit '"
<< test_suite_name << "'";
*/ |
| 536: GTEST_LOG_ ( ERROR ) << "Unknown type parameterized test suit '" |
| 537: << test_suite_name << "'" ; |
| 538: } |
| 539: } |
| 540: |
| 541: void TypeParameterizedTestSuiteRegistry :: CheckForInstantiations ( ) { |
| 542: const auto & ignored = * GetIgnoredParameterizedTestSuites ( ) ; |
| 543: for ( const auto & testcase : suites_ ) { |
544: if/* if (testcase.second.instantiated) continue */ testcase . second . instantiated ) continue ; |
545: if/* if (ignored.find(testcase.first) != ignored.end()) continue */ ignored . find ( testcase . first ) != ignored . end ( ) ) continue ; |
| 546: |
| 547: std :: string message = |
| 548: "Type parameterized test suite " + testcase . first + |
| 549: " is defined via REGISTER_TYPED_TEST_SUITE_P, but never instantiated " |
| 550: "via INSTANTIATE_TYPED_TEST_SUITE_P. None of the test cases will run." |
| 551: "\n\n" |
| 552: "Ideally, TYPED_TEST_P definitions should only ever be included as " |
| 553: "part of binaries that intend to use them. (As opposed to, for " |
| 554: "example, being placed in a library that may be linked in to get other " |
| 555: "utilities.)" |
| 556: "\n\n" |
| 557: "To suppress this error for this test suite, insert the following line " |
| 558: "(in a non-header) in the namespace it is defined in:" |
| 559: "\n\n" |
| 560: "GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(" + |
| 561: testcase . first + ");" ; |
| 562: |
| 563: std :: string full_name = |
| 564: "UninstantiatedTypeParameterizedTestSuite<" + testcase . first + ">" ; |
| 565: RegisterTest ( |
| 566: "GoogleTestVerification" , full_name . c_str ( ) , |
| 567: nullptr , |
| 568: nullptr , |
| 569: testcase . second . code_location . file . c_str ( ) , |
| 570: testcase . second . code_location . line , [ message , testcase ] { |
| 571: return new FailureTest ( testcase . second . code_location , message , |
| 572: kErrorOnUninstantiatedTypeParameterizedTest ) ; |
| 573: } ) ; |
| 574: } |
| 575: } |
| 576: |
| 577: |
| 578: static :: std :: vector < std :: string > g_argvs ; |
| 579: |
| 580: :: std :: vector < std :: string > GetArgvs ( ) { |
| 581: # if defined ( GTEST_CUSTOM_GET_ARGVS_ ) |
| 582: |
| 583: |
| 584: const auto & custom = GTEST_CUSTOM_GET_ARGVS_ ( ) ; |
| 585: return :: std :: vector < std :: string > ( custom . begin ( ) , custom . end ( ) ) ; |
| 586: # else |
| 587: return g_argvs ; |
| 588: # endif |
| 589: } |
| 590: |
| 591: |
| 592: |
| 593: FilePath GetCurrentExecutableName ( ) { |
| 594: FilePath result ; |
| 595: |
| 596: # if GTEST_OS_WINDOWS || GTEST_OS_OS2 |
| 597: result . Set ( FilePath ( GetArgvs ( ) [ 0 ] ) . RemoveExtension ( "exe" ) ) ; |
| 598: # else |
| 599: result . Set ( FilePath ( GetArgvs ( ) [ 0 ] ) ) ; |
| 600: # endif |
| 601: |
| 602: return result . RemoveDirectoryName ( ) ; |
| 603: } |
| 604: |
| 605: |
| 606: |
| 607: |
| 608: std :: string UnitTestOptions :: GetOutputFormat ( ) { |
| 609: const char * const gtest_output_flag = GTEST_FLAG ( output ) . c_str ( ) ; |
| 610: const char * const colon = strchr ( gtest_output_flag , ':' ) ; |
| 611: return colon == nullptr ) |
| 612: ? std :: string ( gtest_output_flag ) |
| 613: : std :: string ( gtest_output_flag , |
| 614: static_cast < size_t > ( colon - gtest_output_flag ) ) ; |
| 615: } |
| 616: |
| 617: |
| 618: |
| 619: std :: string UnitTestOptions :: GetAbsolutePathToOutputFile ( ) { |
| 620: const char * const gtest_output_flag = GTEST_FLAG ( output ) . c_str ( ) ; |
| 621: |
| 622: std :: string format = GetOutputFormat ( ) ; |
623: if/* if (format.empty())
format = std::string(kDefaultOutputFormat) */ format . empty ( ) ) |
| 624: format = std :: string ( kDefaultOutputFormat ) ; |
| 625: |
| 626: const char * const colon = strchr ( gtest_output_flag , ':' ) ; |
| 627: if colon == nullptr ) |
| 628: return internal :: FilePath :: MakeFileName ( |
| 629: internal :: FilePath ( |
| 630: UnitTest :: GetInstance ( ) -> original_working_dir ( ) ) , |
| 631: internal :: FilePath ( kDefaultOutputFile ) , 0 , |
| 632: format . c_str ( ) ) . string ( ) ; |
| 633: |
| 634: internal :: FilePath output_name ( colon + 1 ) ; |
635: if/* if (!output_name.IsAbsolutePath())
output_name = internal::FilePath::ConcatPaths(
internal::FilePath(UnitTest::GetInstance()->original_working_dir()),
internal::FilePath(colon + 1)) */ (truefalse!!output_name.IsAbsolutePath() ! output_name . IsAbsolutePath ( ) ) |
| 636: output_name = internal :: FilePath :: ConcatPaths ( |
| 637: internal :: FilePath ( UnitTest :: GetInstance ( ) -> original_working_dir ( ) ) , |
| 638: internal :: FilePath ( colon + 1 ) ) ; |
| 639: |
| 640: if (truefalse!!output_name.IsDirectory() ! output_name . IsDirectory ( ) ) |
| 641: return output_name . string ( ) ; |
| 642: |
| 643: internal :: FilePath result ( internal :: FilePath :: GenerateUniqueFileName ( |
| 644: output_name , internal :: GetCurrentExecutableName ( ) , |
| 645: GetOutputFormat ( ) . c_str ( ) ) ) ; |
| 646: return result . string ( ) ; |
| 647: } |
| 648: |
| 649: |
| 650: |
| 651: |
| 652: |
| 653: |
| 654: |
| 655: static bool PatternMatchesString ( const std :: string & name_str , |
| 656: const char * pattern , const char * pattern_end ) { |
| 657: const char * name = name_str . c_str ( ) ; |
| 658: const char * const name_begin = name ; |
| 659: const char * const name_end = name + name_str . size ( ) ; |
| 660: |
| 661: const char * pattern_next = pattern ; |
| 662: const char * name_next = name ; |
| 663: |
| 664: while (truefalsetruefalsetruefalse pattern < pattern_end < name_end ) { |
665: if/* if (pattern < pattern_end) {
switch (*pattern) {
default: // Match an ordinary character.
if (name < name_end && *name == *pattern) {
++pattern;
++name;
continue;
}
break;
case '?': // Match any single character.
if (name < name_end) {
++pattern;
++name;
continue;
}
break;
case '*':
// Match zero or more characters. Start by skipping over the wildcard
// and matching zero characters from name. If that fails, restart and
// match one more character than the last attempt.
pattern_next = pattern;
name_next = name + 1;
++pattern;
continue;
}
} */ pattern < pattern_end ) {/*
switch (*pattern) {
default: // Match an ordinary character.
if (name < name_end && *name == *pattern) {
++pattern;
++name;
continue;
}
break;
case '?': // Match any single character.
if (name < name_end) {
++pattern;
++name;
continue;
}
break;
case '*':
// Match zero or more characters. Start by skipping over the wildcard
// and matching zero characters from name. If that fails, restart and
// match one more character than the last attempt.
pattern_next = pattern;
name_next = name + 1;
++pattern;
continue;
}
*/ |
666: switch/* switch (*pattern) {
default: // Match an ordinary character.
if (name < name_end && *name == *pattern) {
++pattern;
++name;
continue;
}
break;
case '?': // Match any single character.
if (name < name_end) {
++pattern;
++name;
continue;
}
break;
case '*':
// Match zero or more characters. Start by skipping over the wildcard
// and matching zero characters from name. If that fails, restart and
// match one more character than the last attempt.
pattern_next = pattern;
name_next = name + 1;
++pattern;
continue;
} */ ( * pattern ) { |
| 667: default : |
668: if/* if (name < name_end && *name == *pattern) {
++pattern;
++name;
continue;
} */ (truefalsetruefalsetruefalse name < name_end name == * pattern ) {/*
++pattern;
++name;
continue;
*/ |
| 669: pattern ; |
| 670: name ; |
| 671: continue ; |
| 672: } |
| 673: break ; |
| 674: case '?' : |
675: if/* if (name < name_end) {
++pattern;
++name;
continue;
} */ name < name_end ) {/*
++pattern;
++name;
continue;
*/ |
| 676: pattern ; |
| 677: name ; |
| 678: continue ; |
| 679: } |
| 680: break ; |
| 681: case '*' : |
| 682: |
| 683: |
| 684: |
685: pattern_next/* pattern_next = pattern */ = pattern ; |
686: name_next/* name_next = name + 1 */ = name + 1 ; |
| 687: pattern ; |
| 688: continue ; |
| 689: } |
| 690: } |
| 691: |
692: if/* if (name_begin < name_next && name_next <= name_end) {
pattern = pattern_next;
name = name_next;
continue;
} */ (truefalsetruefalsetruefalse name_begin < name_next <= name_end ) {/*
pattern = pattern_next;
name = name_next;
continue;
*/ |
693: pattern/* pattern = pattern_next */ = pattern_next ; |
694: name/* name = name_next */ = name_next ; |
| 695: continue ; |
| 696: } |
| 697: return ; |
| 698: } |
| 699: return ; |
| 700: } |
| 701: |
| 702: bool UnitTestOptions :: MatchesFilter ( const std :: string & name_str , |
| 703: const char * filter ) { |
| 704: |
| 705: const char * pattern = filter ; |
| 706: while ( true ) { |
| 707: |
| 708: const char * const next_sep = strchr ( pattern , ':' ) ; |
| 709: const char * const pattern_end = |
| 710: != nullptr ? next_sep : pattern + strlen ( pattern ) ; |
| 711: |
| 712: |
| 713: if PatternMatchesString ( name_str , pattern , pattern_end ) ) { |
| 714: return ; |
| 715: } |
| 716: |
| 717: |
| 718: |
| 719: if next_sep == nullptr ) { |
| 720: return ; |
| 721: } |
722: pattern/* pattern = next_sep + 1 */ = next_sep + 1 ; |
| 723: } |
| 724: return ; |
| 725: } |
| 726: |
| 727: |
| 728: |
| 729: bool UnitTestOptions :: FilterMatchesTest ( const std :: string & test_suite_name , |
| 730: const std :: string & test_name ) { |
| 731: const std :: string & full_name = test_suite_name + "." + test_name . c_str ( ) ; |
| 732: |
| 733: |
| 734: |
| 735: const char * const p = GTEST_FLAG ( filter ) . c_str ( ) ; |
| 736: const char * const dash = strchr ( p , '-' ) ; |
| 737: std :: string positive ; |
| 738: std :: string negative ; |
739: if/* if (dash == nullptr) {
positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
negative = "";
} else {
positive = std::string(p, dash); // Everything up to the dash
negative = std::string(dash + 1); // Everything after the dash
if (positive.empty()) {
// Treat '-test1' as the same as '*-test1'
positive = kUniversalFilter;
}
} */ dash == nullptr ) {/*
positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
negative = "";
*/ |
740: positive/* positive = GTEST_FLAG(filter).c_str() */ = GTEST_FLAG ( filter ) . c_str ( ) ; |
741: negative/* negative = "" */ = "" ; |
| 742: } else {/*
positive = std::string(p, dash); // Everything up to the dash
negative = std::string(dash + 1); // Everything after the dash
if (positive.empty()) {
// Treat '-test1' as the same as '*-test1'
positive = kUniversalFilter;
}
*/ |
| 743: positive = std :: string ( p , dash ) ; |
| 744: negative = std :: string ( dash + 1 ) ; |
745: if/* if (positive.empty()) {
// Treat '-test1' as the same as '*-test1'
positive = kUniversalFilter;
} */ positive . empty ( ) ) {/*
// Treat '-test1' as the same as '*-test1'
positive = kUniversalFilter;
*/ |
| 746: |
747: positive/* positive = kUniversalFilter */ = kUniversalFilter ; |
| 748: } |
| 749: } |
| 750: |
| 751: |
| 752: |
| 753: return (truefalsetruefalsetruefalse MatchesFilter ( full_name , positive . c_str ( ) ) |
754: !!!MatchesFilter(full_name, negative.c_str()) MatchesFilter ( full_name , negative . c_str ( ) ) ) ; |
| 755: } |
| 756: |
| 757: # if GTEST_HAS_SEH |
| 758: |
| 759: |
| 760: |
| 761: int UnitTestOptions :: GTestShouldProcessSEH ( DWORD exception_code ) { |
| 762: |
| 763: |
| 764: |
| 765: |
| 766: |
| 767: |
| 768: |
| 769: |
| 770: const DWORD kCxxExceptionCode = 0xe06d7363 ; |
| 771: |
| 772: bool should_handle = true ; |
| 773: |
| 774: if ( ! GTEST_FLAG ( catch_exceptions ) ) |
| 775: should_handle = false ; |
| 776: else if ( exception_code == EXCEPTION_BREAKPOINT ) |
| 777: should_handle = false ; |
| 778: else if ( exception_code == kCxxExceptionCode ) |
| 779: should_handle = false ; |
| 780: |
| 781: return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH ; |
| 782: } |
| 783: # endif |
| 784: |
| 785: } |
| 786: |
| 787: |
| 788: |
| 789: |
| 790: ScopedFakeTestPartResultReporter :: ScopedFakeTestPartResultReporter ( |
| 791: TestPartResultArray * result ) |
| 792: : intercept_mode_ ( INTERCEPT_ONLY_CURRENT_THREAD ) , |
| 793: result_ ( result ) |
| 794: Init ( ) ; |
| 795: } |
| 796: |
| 797: |
| 798: |
| 799: |
| 800: ScopedFakeTestPartResultReporter :: ScopedFakeTestPartResultReporter ( |
| 801: InterceptMode intercept_mode , TestPartResultArray * result ) |
| 802: : intercept_mode_ ( intercept_mode ) , |
| 803: result_ ( result ) |
| 804: Init ( ) ; |
| 805: } |
| 806: |
| 807: void ScopedFakeTestPartResultReporter :: Init ( ) {/*
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
old_reporter_ = impl->GetGlobalTestPartResultReporter();
impl->SetGlobalTestPartResultReporter(this);
} else {
old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
impl->SetTestPartResultReporterForCurrentThread(this);
}
*/ |
| 808: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
809: if/* if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
old_reporter_ = impl->GetGlobalTestPartResultReporter();
impl->SetGlobalTestPartResultReporter(this);
} else {
old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
impl->SetTestPartResultReporterForCurrentThread(this);
} */ intercept_mode_ == INTERCEPT_ALL_THREADS ) {/*
old_reporter_ = impl->GetGlobalTestPartResultReporter();
impl->SetGlobalTestPartResultReporter(this);
*/ |
810: old_reporter_/* old_reporter_ = impl->GetGlobalTestPartResultReporter() */ = impl -> GetGlobalTestPartResultReporter ( ) ; |
811: impl/* impl->SetGlobalTestPartResultReporter(this) */ -> SetGlobalTestPartResultReporter ( this ) ; |
| 812: } else {/*
old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
impl->SetTestPartResultReporterForCurrentThread(this);
*/ |
813: old_reporter_/* old_reporter_ = impl->GetTestPartResultReporterForCurrentThread() */ = impl -> GetTestPartResultReporterForCurrentThread ( ) ; |
814: impl/* impl->SetTestPartResultReporterForCurrentThread(this) */ -> SetTestPartResultReporterForCurrentThread ( this ) ; |
| 815: } |
| 816: } |
| 817: |
| 818: |
| 819: |
| 820: ScopedFakeTestPartResultReporter :: ~ ScopedFakeTestPartResultReporter ( ) {/*
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
impl->SetGlobalTestPartResultReporter(old_reporter_);
} else {
impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
}
*/ |
| 821: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
822: if/* if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
impl->SetGlobalTestPartResultReporter(old_reporter_);
} else {
impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
} */ intercept_mode_ == INTERCEPT_ALL_THREADS ) {/*
impl->SetGlobalTestPartResultReporter(old_reporter_);
*/ |
| 823: impl -> SetGlobalTestPartResultReporter ( old_reporter_ ) ; |
| 824: } else {/*
impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
*/ |
| 825: impl -> SetTestPartResultReporterForCurrentThread ( old_reporter_ ) ; |
| 826: } |
| 827: } |
| 828: |
| 829: |
| 830: |
| 831: void ScopedFakeTestPartResultReporter :: ReportTestPartResult ( |
| 832: const TestPartResult & result ) {/*
result_->Append(result);
*/ |
833: result_/* result_->Append(result) */ -> Append ( result ) ; |
| 834: } |
| 835: |
| 836: namespace internal { |
| 837: |
| 838: |
| 839: |
| 840: |
| 841: |
| 842: |
| 843: |
| 844: |
| 845: |
| 846: |
| 847: TypeId GetTestTypeId ( ) { |
| 848: return GetTypeId < Test > ( ) ; |
| 849: } |
| 850: |
| 851: |
| 852: |
| 853: extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId ( ) ; |
| 854: |
| 855: |
| 856: |
| 857: |
| 858: static AssertionResult HasOneFailure ( const char * , |
| 859: const char * , |
| 860: const char * , |
| 861: const TestPartResultArray & results , |
| 862: TestPartResult :: Type type , |
| 863: const std :: string & substr ) { |
| 864: const std :: string expected type == TestPartResult :: kFatalFailure ? |
| 865: "1 fatal failure" : |
| 866: "1 non-fatal failure" ) ; |
| 867: Message msg ; |
| 868: if results . size ( ) != 1 ) { |
| 869: msg << "Expected: " << expected << "\n" |
| 870: << " Actual: " << results . size ( ) << " failures" ; |
871: for/* for (int i = 0; i < results.size(); i++) {
msg << "\n" << results.GetTestPartResult(i);
} */ ( int i = 0 ; i < results . size ( ) ; i ++ ) {/*
msg << "\n" << results.GetTestPartResult(i);
*/ |
872: msg/* msg << "\n" << results.GetTestPartResult(i) */ << "\n" << results . GetTestPartResult ( i ) ; |
| 873: } |
| 874: return AssertionFailure ( ) << msg ; |
| 875: } |
| 876: |
| 877: const TestPartResult & r = results . GetTestPartResult ( 0 ) ; |
| 878: if r . type ( ) != type ) { |
| 879: return AssertionFailure ( ) << "Expected: " << expected << "\n" |
| 880: << " Actual:\n" |
| 881: << r ; |
| 882: } |
| 883: |
| 884: if strstr ( r . message ( ) , substr . c_str ( ) ) == nullptr ) { |
| 885: return AssertionFailure ( ) << "Expected: " << expected << " containing \"" |
| 886: << substr << "\"\n" |
| 887: << " Actual:\n" |
| 888: << r ; |
| 889: } |
| 890: |
| 891: return AssertionSuccess ( ) ; |
| 892: } |
| 893: |
| 894: |
| 895: |
| 896: |
| 897: SingleFailureChecker :: SingleFailureChecker ( const TestPartResultArray * results , |
| 898: TestPartResult :: Type type , |
| 899: const std :: string & substr ) |
| 900: : results_ ( results ) , type_ ( type ) , substr_ ( substr ) { } |
| 901: |
| 902: |
| 903: |
| 904: |
| 905: |
| 906: SingleFailureChecker :: ~ SingleFailureChecker ( ) {/*
EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);
*/ |
| 907: EXPECT_PRED_FORMAT3 ( HasOneFailure , * results_ , type_ , substr_ ) ; |
| 908: } |
| 909: |
| 910: DefaultGlobalTestPartResultReporter :: DefaultGlobalTestPartResultReporter ( |
| 911: UnitTestImpl * unit_test ) : unit_test_ ( unit_test ) { } |
| 912: |
| 913: void DefaultGlobalTestPartResultReporter :: ReportTestPartResult ( |
| 914: const TestPartResult & result ) {/*
unit_test_->current_test_result()->AddTestPartResult(result);
unit_test_->listeners()->repeater()->OnTestPartResult(result);
*/ |
915: unit_test_/* unit_test_->current_test_result()->AddTestPartResult(result) */ -> current_test_result ( ) -> AddTestPartResult ( result ) ; |
916: unit_test_/* unit_test_->listeners()->repeater()->OnTestPartResult(result) */ -> listeners ( ) -> repeater ( ) -> OnTestPartResult ( result ) ; |
| 917: } |
| 918: |
| 919: DefaultPerThreadTestPartResultReporter :: DefaultPerThreadTestPartResultReporter ( |
| 920: UnitTestImpl * unit_test ) : unit_test_ ( unit_test ) { } |
| 921: |
| 922: void DefaultPerThreadTestPartResultReporter :: ReportTestPartResult ( |
| 923: const TestPartResult & result ) {/*
unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);
*/ |
924: unit_test_/* unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result) */ -> GetGlobalTestPartResultReporter ( ) -> ReportTestPartResult ( result ) ; |
| 925: } |
| 926: |
| 927: |
| 928: TestPartResultReporterInterface * |
| 929: UnitTestImpl :: GetGlobalTestPartResultReporter ( ) { |
| 930: internal :: MutexLock lock ( & global_test_part_result_reporter_mutex_ ) ; |
| 931: return global_test_part_result_repoter_ ; |
| 932: } |
| 933: |
| 934: |
| 935: void UnitTestImpl :: SetGlobalTestPartResultReporter ( |
| 936: TestPartResultReporterInterface * reporter ) {/*
internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
global_test_part_result_repoter_ = reporter;
*/ |
| 937: internal :: MutexLock lock ( & global_test_part_result_reporter_mutex_ ) ; |
938: global_test_part_result_repoter_/* global_test_part_result_repoter_ = reporter */ = reporter ; |
| 939: } |
| 940: |
| 941: |
| 942: TestPartResultReporterInterface * |
| 943: UnitTestImpl :: GetTestPartResultReporterForCurrentThread ( ) { |
| 944: return per_thread_test_part_result_reporter_ . get ( ) ; |
| 945: } |
| 946: |
| 947: |
| 948: void UnitTestImpl :: SetTestPartResultReporterForCurrentThread ( |
| 949: TestPartResultReporterInterface * reporter ) {/*
per_thread_test_part_result_reporter_.set(reporter);
*/ |
950: per_thread_test_part_result_reporter_/* per_thread_test_part_result_reporter_.set(reporter) */ . set ( reporter ) ; |
| 951: } |
| 952: |
| 953: |
| 954: int UnitTestImpl :: successful_test_suite_count ( ) const { |
| 955: return CountIf ( test_suites_ , TestSuitePassed ) ; |
| 956: } |
| 957: |
| 958: |
| 959: int UnitTestImpl :: failed_test_suite_count ( ) const { |
| 960: return CountIf ( test_suites_ , TestSuiteFailed ) ; |
| 961: } |
| 962: |
| 963: |
| 964: int UnitTestImpl :: total_test_suite_count ( ) const { |
| 965: return static_cast < int > ( test_suites_ . size ( ) ) ; |
| 966: } |
| 967: |
| 968: |
| 969: |
| 970: int UnitTestImpl :: test_suite_to_run_count ( ) const { |
| 971: return CountIf ( test_suites_ , ShouldRunTestSuite ) ; |
| 972: } |
| 973: |
| 974: |
| 975: int UnitTestImpl :: successful_test_count ( ) const { |
| 976: return SumOverTestSuiteList ( test_suites_ , & TestSuite :: successful_test_count ) ; |
| 977: } |
| 978: |
| 979: |
| 980: int UnitTestImpl :: skipped_test_count ( ) const { |
| 981: return SumOverTestSuiteList ( test_suites_ , & TestSuite :: skipped_test_count ) ; |
| 982: } |
| 983: |
| 984: |
| 985: int UnitTestImpl :: failed_test_count ( ) const { |
| 986: return SumOverTestSuiteList ( test_suites_ , & TestSuite :: failed_test_count ) ; |
| 987: } |
| 988: |
| 989: |
| 990: int UnitTestImpl :: reportable_disabled_test_count ( ) const { |
| 991: return SumOverTestSuiteList ( test_suites_ , |
| 992: & TestSuite :: reportable_disabled_test_count ) ; |
| 993: } |
| 994: |
| 995: |
| 996: int UnitTestImpl :: disabled_test_count ( ) const { |
| 997: return SumOverTestSuiteList ( test_suites_ , & TestSuite :: disabled_test_count ) ; |
| 998: } |
| 999: |
| 1000: |
| 1001: int UnitTestImpl :: reportable_test_count ( ) const { |
| 1002: return SumOverTestSuiteList ( test_suites_ , & TestSuite :: reportable_test_count ) ; |
| 1003: } |
| 1004: |
| 1005: |
| 1006: int UnitTestImpl :: total_test_count ( ) const { |
| 1007: return SumOverTestSuiteList ( test_suites_ , & TestSuite :: total_test_count ) ; |
| 1008: } |
| 1009: |
| 1010: |
| 1011: int UnitTestImpl :: test_to_run_count ( ) const { |
| 1012: return SumOverTestSuiteList ( test_suites_ , & TestSuite :: test_to_run_count ) ; |
| 1013: } |
| 1014: |
| 1015: |
| 1016: |
| 1017: |
| 1018: |
| 1019: |
| 1020: |
| 1021: |
| 1022: |
| 1023: |
| 1024: |
| 1025: std :: string UnitTestImpl :: CurrentOsStackTraceExceptTop ( int skip_count ) { |
| 1026: return os_stack_trace_getter ( ) -> CurrentStackTrace ( |
| 1027: static_cast < int > ( GTEST_FLAG ( stack_trace_depth ) ) , |
| 1028: skip_count + 1 |
| 1029: |
| 1030: |
| 1031: ) ; |
| 1032: } |
| 1033: |
| 1034: |
| 1035: class Timer { |
| 1036: public : |
| 1037: Timer ( ) : start_ ( std :: chrono :: steady_clock :: now ( ) ) { } |
| 1038: |
| 1039: |
| 1040: TimeInMillis Elapsed ( ) { |
| 1041: return std :: chrono :: duration_cast < std :: chrono :: milliseconds > ( |
| 1042: std :: chrono :: steady_clock :: now ( ) - start_ ) |
| 1043: . count ( ) ; |
| 1044: } |
| 1045: |
| 1046: private : |
| 1047: std :: chrono :: steady_clock :: time_point start_ ; |
| 1048: } ; |
| 1049: |
| 1050: |
| 1051: |
| 1052: |
| 1053: TimeInMillis GetTimeInMillis ( ) { |
| 1054: return std :: chrono :: duration_cast < std :: chrono :: milliseconds > ( |
| 1055: std :: chrono :: system_clock :: now ( ) - |
| 1056: std :: chrono :: system_clock :: from_time_t ( 0 ) ) |
| 1057: . count ( ) ; |
| 1058: } |
| 1059: |
| 1060: |
| 1061: |
| 1062: |
| 1063: |
| 1064: # if GTEST_OS_WINDOWS_MOBILE |
| 1065: |
| 1066: |
| 1067: |
| 1068: |
| 1069: LPCWSTR String :: AnsiToUtf16 ( const char * ansi ) { |
| 1070: if ( ! ansi ) return nullptr ; |
| 1071: const int length = strlen ( ansi ) ; |
| 1072: const int unicode_length = |
| 1073: MultiByteToWideChar ( CP_ACP , 0 , ansi , length , nullptr , 0 ) ; |
| 1074: WCHAR * unicode = new WCHAR [ unicode_length + 1 ] ; |
| 1075: MultiByteToWideChar ( CP_ACP , 0 , ansi , length , |
| 1076: unicode , unicode_length ) ; |
| 1077: unicode [ unicode_length ] = 0 ; |
| 1078: return unicode ; |
| 1079: } |
| 1080: |
| 1081: |
| 1082: |
| 1083: |
| 1084: |
| 1085: const char * String :: Utf16ToAnsi ( LPCWSTR utf16_str ) { |
| 1086: if ( ! utf16_str ) return nullptr ; |
| 1087: const int ansi_length = WideCharToMultiByte ( CP_ACP , 0 , utf16_str , - 1 , nullptr , |
| 1088: 0 , nullptr , nullptr ) ; |
| 1089: char * ansi = new char [ ansi_length + 1 ] ; |
| 1090: WideCharToMultiByte ( CP_ACP , 0 , utf16_str , - 1 , ansi , ansi_length , nullptr , |
| 1091: nullptr ) ; |
| 1092: ansi [ ansi_length ] = 0 ; |
| 1093: return ansi ; |
| 1094: } |
| 1095: |
| 1096: # endif |
| 1097: |
| 1098: |
| 1099: |
| 1100: |
| 1101: |
| 1102: |
| 1103: |
| 1104: bool String :: CStringEquals ( const char * lhs , const char * rhs ) { |
| 1105: if lhs == nullptr ) return == nullptr ; |
| 1106: |
| 1107: if rhs == nullptr ) return ; |
| 1108: |
| 1109: return ( lhs , rhs ) == 0 ; |
| 1110: } |
| 1111: |
| 1112: # if GTEST_HAS_STD_WSTRING |
| 1113: |
| 1114: |
| 1115: |
| 1116: static void StreamWideCharsToMessage ( const wchar_t * wstr , size_t length , |
| 1117: Message * msg ) {/*
for (size_t i = 0; i != length; ) { // NOLINT
if (wstr[i] != L'\0') {
*msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
while (i != length && wstr[i] != L'\0')
i++;
} else {
*msg << '\0';
i++;
}
}
*/ |
1118: for/* for (size_t i = 0; i != length; ) { // NOLINT
if (wstr[i] != L'\0') {
*msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
while (i != length && wstr[i] != L'\0')
i++;
} else {
*msg << '\0';
i++;
}
} */ ( size_t i = 0 ; i != length ; ) {/* // NOLINT
if (wstr[i] != L'\0') {
*msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
while (i != length && wstr[i] != L'\0')
i++;
} else {
*msg << '\0';
i++;
}
*/ |
1119: if/* if (wstr[i] != L'\0') {
*msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
while (i != length && wstr[i] != L'\0')
i++;
} else {
*msg << '\0';
i++;
} */ wstr [ i ] != L'\0' ) {/*
*msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
while (i != length && wstr[i] != L'\0')
i++;
*/ |
| 1120: * msg << WideStringToUtf8 ( wstr + i , static_cast < int > ( length - i ) ) ; |
1121: while/* while (i != length && wstr[i] != L'\0')
i++ */ (truefalsetruefalsetruefalse i != length [ i ] != L'\0' ) |
| 1122: i ++ ; |
| 1123: } else {/*
*msg << '\0';
i++;
*/ |
| 1124: * msg << '\0' ; |
| 1125: ++ ; |
| 1126: } |
| 1127: } |
| 1128: } |
| 1129: |
| 1130: # endif |
| 1131: |
| 1132: void SplitString ( const :: std :: string & str , char delimiter , |
| 1133: :: std :: vector < :: std :: string > * dest ) {/*
::std::vector< ::std::string> parsed;
::std::string::size_type pos = 0;
while (::testing::internal::AlwaysTrue()) {
const ::std::string::size_type colon = str.find(delimiter, pos);
if (colon == ::std::string::npos) {
parsed.push_back(str.substr(pos));
break;
} else {
parsed.push_back(str.substr(pos, colon - pos));
pos = colon + 1;
}
}
dest->swap(parsed);
*/ |
| 1134: :: std :: vector < :: std :: string > parsed ; |
| 1135: :: std :: string :: size_type pos = 0 ; |
1136: while/* while (::testing::internal::AlwaysTrue()) {
const ::std::string::size_type colon = str.find(delimiter, pos);
if (colon == ::std::string::npos) {
parsed.push_back(str.substr(pos));
break;
} else {
parsed.push_back(str.substr(pos, colon - pos));
pos = colon + 1;
}
} */ ( :: testing :: internal :: AlwaysTrue ( ) ) {/*
const ::std::string::size_type colon = str.find(delimiter, pos);
if (colon == ::std::string::npos) {
parsed.push_back(str.substr(pos));
break;
} else {
parsed.push_back(str.substr(pos, colon - pos));
pos = colon + 1;
}
*/ |
| 1137: const :: std :: string :: size_type colon = str . find ( delimiter , pos ) ; |
1138: if/* if (colon == ::std::string::npos) {
parsed.push_back(str.substr(pos));
break;
} else {
parsed.push_back(str.substr(pos, colon - pos));
pos = colon + 1;
} */ colon == :: std :: string :: npos ) {/*
parsed.push_back(str.substr(pos));
break;
*/ |
| 1139: parsed . push_back ( str . substr ( pos ) ) ; |
| 1140: break ; |
| 1141: } else {/*
parsed.push_back(str.substr(pos, colon - pos));
pos = colon + 1;
*/ |
| 1142: parsed . push_back ( str . substr ( pos , colon - pos ) ) ; |
| 1143: = colon + 1 ; |
| 1144: } |
| 1145: } |
1146: dest/* dest->swap(parsed) */ -> swap ( parsed ) ; |
| 1147: } |
| 1148: |
| 1149: } |
| 1150: |
| 1151: |
| 1152: |
| 1153: |
| 1154: |
| 1155: |
| 1156: Message :: Message ( ) : ss_ ( new :: std :: stringstream ) {/*
// By default, we want there to be enough precision when printing
// a double to a Message.
*ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
*/ |
| 1157: |
| 1158: |
| 1159: * ss_ << std :: setprecision ( std :: numeric_limits < double > :: digits10 + 2 ) ; |
| 1160: } |
| 1161: |
| 1162: |
| 1163: |
| 1164: Message & Message :: operator << ( const wchar_t * wide_c_str ) { |
| 1165: return * this << internal :: String :: ShowWideCString ( wide_c_str ) ; |
| 1166: } |
| 1167: Message & Message :: operator << ( wchar_t * wide_c_str ) { |
| 1168: return * this << internal :: String :: ShowWideCString ( wide_c_str ) ; |
| 1169: } |
| 1170: |
| 1171: # if GTEST_HAS_STD_WSTRING |
| 1172: |
| 1173: |
| 1174: Message & Message :: operator << ( const :: std :: wstring & wstr ) { |
1175: internal/* internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this) */ :: StreamWideCharsToMessage ( wstr . c_str ( ) , wstr . length ( ) , this ) ; |
| 1176: return * this ; |
| 1177: } |
| 1178: # endif |
| 1179: |
| 1180: |
| 1181: |
| 1182: std :: string Message :: GetString ( ) const { |
| 1183: return internal :: StringStreamToString ( ss_ . get ( ) ) ; |
| 1184: } |
| 1185: |
| 1186: |
| 1187: |
| 1188: AssertionResult :: AssertionResult ( const AssertionResult & other ) |
| 1189: : success_ ( other . success_ ) , |
| 1190: message_ other . message_ . get ( ) != nullptr |
| 1191: ? new :: std :: string ( * other . message_ ) |
| 1192: : static_cast < :: std :: string * > ( nullptr ) ) { } |
| 1193: |
| 1194: |
| 1195: void AssertionResult :: swap ( AssertionResult & other ) {/*
using std::swap;
swap(success_, other.success_);
swap(message_, other.message_);
*/ |
| 1196: using std :: swap ; |
1197: swap/* swap(success_, other.success_) */ ( success_ , other . success_ ) ; |
1198: swap/* swap(message_, other.message_) */ ( message_ , other . message_ ) ; |
| 1199: } |
| 1200: |
| 1201: |
| 1202: AssertionResult AssertionResult :: operator ! ( ) const { |
| 1203: AssertionResult negation ! success_ ) ; |
1204: if/* if (message_.get() != nullptr) negation << *message_ */ message_ . get ( ) != nullptr ) negation << * message_ ; |
| 1205: return negation ; |
| 1206: } |
| 1207: |
| 1208: |
| 1209: AssertionResult AssertionSuccess ( ) { |
| 1210: return AssertionResult ( true ) ; |
| 1211: } |
| 1212: |
| 1213: |
| 1214: AssertionResult AssertionFailure ( ) { |
| 1215: return AssertionResult ( false ) ; |
| 1216: } |
| 1217: |
| 1218: |
| 1219: |
| 1220: AssertionResult AssertionFailure ( const Message & message ) { |
| 1221: return AssertionFailure ( ) << message ; |
| 1222: } |
| 1223: |
| 1224: namespace internal { |
| 1225: |
| 1226: namespace edit_distance { |
| 1227: std :: vector < EditType > CalculateOptimalEdits ( const std :: vector < size_t > & left , |
| 1228: const std :: vector < size_t > & right ) { |
| 1229: std :: vector < std :: vector < double > > costs ( |
| 1230: left . size ( ) + 1 , std :: vector < double > ( right . size ( ) + 1 ) ) ; |
| 1231: std :: vector < std :: vector < EditType > > best_move ( |
| 1232: left . size ( ) + 1 , std :: vector < EditType > ( right . size ( ) + 1 ) ) ; |
| 1233: |
| 1234: |
1235: for/* for (size_t l_i = 0; l_i < costs.size(); ++l_i) {
costs[l_i][0] = static_cast<double>(l_i);
best_move[l_i][0] = kRemove;
} */ ( size_t l_i = 0 ; l_i < costs . size ( ) ; ++ l_i ) {/*
costs[l_i][0] = static_cast<double>(l_i);
best_move[l_i][0] = kRemove;
*/ |
1236: costs/* costs[l_i][0] = static_cast<double>(l_i) */ [ l_i ] [ 0 ] = static_cast < double > ( l_i ) ; |
1237: best_move/* best_move[l_i][0] = kRemove */ [ l_i ] [ 0 ] = kRemove ; |
| 1238: } |
| 1239: |
1240: for/* for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) {
costs[0][r_i] = static_cast<double>(r_i);
best_move[0][r_i] = kAdd;
} */ ( size_t r_i = 1 ; r_i < costs [ 0 ] . size ( ) ; ++ r_i ) {/*
costs[0][r_i] = static_cast<double>(r_i);
best_move[0][r_i] = kAdd;
*/ |
1241: costs/* costs[0][r_i] = static_cast<double>(r_i) */ [ 0 ] [ r_i ] = static_cast < double > ( r_i ) ; |
1242: best_move/* best_move[0][r_i] = kAdd */ [ 0 ] [ r_i ] = kAdd ; |
| 1243: } |
| 1244: |
1245: for/* for (size_t l_i = 0; l_i < left.size(); ++l_i) {
for (size_t r_i = 0; r_i < right.size(); ++r_i) {
if (left[l_i] == right[r_i]) {
// Found a match. Consume it.
costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
best_move[l_i + 1][r_i + 1] = kMatch;
continue;
}
const double add = costs[l_i + 1][r_i];
const double remove = costs[l_i][r_i + 1];
const double replace = costs[l_i][r_i];
if (add < remove && add < replace) {
costs[l_i + 1][r_i + 1] = add + 1;
best_move[l_i + 1][r_i + 1] = kAdd;
} else if (remove < add && remove < replace) {
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
} else {
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
}
}
} */ ( size_t l_i = 0 ; l_i < left . size ( ) ; ++ l_i ) {/*
for (size_t r_i = 0; r_i < right.size(); ++r_i) {
if (left[l_i] == right[r_i]) {
// Found a match. Consume it.
costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
best_move[l_i + 1][r_i + 1] = kMatch;
continue;
}
const double add = costs[l_i + 1][r_i];
const double remove = costs[l_i][r_i + 1];
const double replace = costs[l_i][r_i];
if (add < remove && add < replace) {
costs[l_i + 1][r_i + 1] = add + 1;
best_move[l_i + 1][r_i + 1] = kAdd;
} else if (remove < add && remove < replace) {
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
} else {
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
}
}
*/ |
1246: for/* for (size_t r_i = 0; r_i < right.size(); ++r_i) {
if (left[l_i] == right[r_i]) {
// Found a match. Consume it.
costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
best_move[l_i + 1][r_i + 1] = kMatch;
continue;
}
const double add = costs[l_i + 1][r_i];
const double remove = costs[l_i][r_i + 1];
const double replace = costs[l_i][r_i];
if (add < remove && add < replace) {
costs[l_i + 1][r_i + 1] = add + 1;
best_move[l_i + 1][r_i + 1] = kAdd;
} else if (remove < add && remove < replace) {
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
} else {
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
}
} */ ( size_t r_i = 0 ; r_i < right . size ( ) ; ++ r_i ) {/*
if (left[l_i] == right[r_i]) {
// Found a match. Consume it.
costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
best_move[l_i + 1][r_i + 1] = kMatch;
continue;
}
const double add = costs[l_i + 1][r_i];
const double remove = costs[l_i][r_i + 1];
const double replace = costs[l_i][r_i];
if (add < remove && add < replace) {
costs[l_i + 1][r_i + 1] = add + 1;
best_move[l_i + 1][r_i + 1] = kAdd;
} else if (remove < add && remove < replace) {
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
} else {
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
}
*/ |
1247: if/* if (left[l_i] == right[r_i]) {
// Found a match. Consume it.
costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
best_move[l_i + 1][r_i + 1] = kMatch;
continue;
} */ left [ l_i ] == right [ r_i ] ) {/*
// Found a match. Consume it.
costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
best_move[l_i + 1][r_i + 1] = kMatch;
continue;
*/ |
| 1248: |
1249: costs/* costs[l_i + 1][r_i + 1] = costs[l_i][r_i] */ [ l_i + 1 ] [ r_i + 1 ] = costs [ l_i ] [ r_i ] ; |
1250: best_move/* best_move[l_i + 1][r_i + 1] = kMatch */ [ l_i + 1 ] [ r_i + 1 ] = kMatch ; |
| 1251: continue ; |
| 1252: } |
| 1253: |
| 1254: const double add = costs [ l_i + 1 ] [ r_i ] ; |
| 1255: const double remove = costs [ l_i ] [ r_i + 1 ] ; |
| 1256: const double replace = costs [ l_i ] [ r_i ] ; |
1257: if/* if (add < remove && add < replace) {
costs[l_i + 1][r_i + 1] = add + 1;
best_move[l_i + 1][r_i + 1] = kAdd;
} else if (remove < add && remove < replace) {
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
} else {
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
} */ (truefalsetruefalsetruefalse add < remove < replace ) {/*
costs[l_i + 1][r_i + 1] = add + 1;
best_move[l_i + 1][r_i + 1] = kAdd;
*/ |
1258: costs/* costs[l_i + 1][r_i + 1] = add + 1 */ [ l_i + 1 ] [ r_i + 1 ] = add + 1 ; |
1259: best_move/* best_move[l_i + 1][r_i + 1] = kAdd */ [ l_i + 1 ] [ r_i + 1 ] = kAdd ; |
| 1260: } else if/* if (remove < add && remove < replace) {
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
} else {
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
} */ (truefalsetruefalsetruefalse remove < add < replace ) {/*
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
*/ |
1261: costs/* costs[l_i + 1][r_i + 1] = remove + 1 */ [ l_i + 1 ] [ r_i + 1 ] = remove + 1 ; |
1262: best_move/* best_move[l_i + 1][r_i + 1] = kRemove */ [ l_i + 1 ] [ r_i + 1 ] = kRemove ; |
| 1263: } else {/*
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
*/ |
| 1264: |
| 1265: |
1266: costs/* costs[l_i + 1][r_i + 1] = replace + 1.00001 */ [ l_i + 1 ] [ r_i + 1 ] = replace + 1.00001 ; |
1267: best_move/* best_move[l_i + 1][r_i + 1] = kReplace */ [ l_i + 1 ] [ r_i + 1 ] = kReplace ; |
| 1268: } |
| 1269: } |
| 1270: } |
| 1271: |
| 1272: |
| 1273: std :: vector < EditType > best_path ; |
1274: for/* for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) {
EditType move = best_move[l_i][r_i];
best_path.push_back(move);
l_i -= move != kAdd;
r_i -= move != kRemove;
} */ ( size_t l_i = left . size ( ) , r_i = right . size ( ) ; l_i > 0 || r_i > 0 ; ) {/*
EditType move = best_move[l_i][r_i];
best_path.push_back(move);
l_i -= move != kAdd;
r_i -= move != kRemove;
*/ |
| 1275: EditType move = best_move [ l_i ] [ r_i ] ; |
1276: best_path/* best_path.push_back(move) */ . push_back ( move ) ; |
1277: l_i/* l_i -= move != kAdd */ -= != kAdd ; |
1278: r_i/* r_i -= move != kRemove */ -= != kRemove ; |
| 1279: } |
| 1280: std :: reverse ( best_path . begin ( ) , best_path . end ( ) ) ; |
| 1281: return best_path ; |
| 1282: } |
| 1283: |
| 1284: namespace { |
| 1285: |
| 1286: |
| 1287: class InternalStrings { |
| 1288: public : |
| 1289: size_t GetId ( const std :: string & str ) { |
| 1290: IdMap :: iterator it = ids_ . find ( str ) ; |
| 1291: if it != ids_ . end ( ) ) return it -> second ; |
| 1292: size_t id = ids_ . size ( ) ; |
| 1293: return ids_ [ str ] = id ; |
| 1294: } |
| 1295: |
| 1296: private : |
| 1297: typedef std :: map < std :: string , size_t > IdMap ; |
| 1298: IdMap ids_ ; |
| 1299: } ; |
| 1300: |
| 1301: } |
| 1302: |
| 1303: std :: vector < EditType > CalculateOptimalEdits ( |
| 1304: const std :: vector < std :: string > & left , |
| 1305: const std :: vector < std :: string > & right ) { |
| 1306: std :: vector < size_t > left_ids , right_ids ; |
1307: {/*
InternalStrings intern_table;
for (size_t i = 0; i < left.size(); ++i) {
left_ids.push_back(intern_table.GetId(left[i]));
}
for (size_t i = 0; i < right.size(); ++i) {
right_ids.push_back(intern_table.GetId(right[i]));
}
*/ |
| 1308: InternalStrings intern_table ; |
1309: for/* for (size_t i = 0; i < left.size(); ++i) {
left_ids.push_back(intern_table.GetId(left[i]));
} */ ( size_t i = 0 ; i < left . size ( ) ; ++ i ) {/*
left_ids.push_back(intern_table.GetId(left[i]));
*/ |
| 1310: left_ids . push_back ( intern_table . GetId ( left [ i ] ) ) ; |
| 1311: } |
1312: for/* for (size_t i = 0; i < right.size(); ++i) {
right_ids.push_back(intern_table.GetId(right[i]));
} */ ( size_t i = 0 ; i < right . size ( ) ; ++ i ) {/*
right_ids.push_back(intern_table.GetId(right[i]));
*/ |
| 1313: right_ids . push_back ( intern_table . GetId ( right [ i ] ) ) ; |
| 1314: } |
| 1315: } |
| 1316: return CalculateOptimalEdits ( left_ids , right_ids ) ; |
| 1317: } |
| 1318: |
| 1319: namespace { |
| 1320: |
| 1321: |
| 1322: |
| 1323: |
| 1324: |
| 1325: class Hunk { |
| 1326: public : |
| 1327: Hunk ( size_t left_start , size_t right_start ) |
| 1328: : left_start_ ( left_start ) , |
| 1329: right_start_ ( right_start ) , |
| 1330: adds_ ( ) , |
| 1331: removes_ ( ) , |
| 1332: common_ ( ) { } |
| 1333: |
| 1334: void PushLine ( char edit , const char * line ) {/*
switch (edit) {
case ' ':
++common_;
FlushEdits();
hunk_.push_back(std::make_pair(' ', line));
break;
case '-':
++removes_;
hunk_removes_.push_back(std::make_pair('-', line));
break;
case '+':
++adds_;
hunk_adds_.push_back(std::make_pair('+', line));
break;
}
*/ |
1335: switch/* switch (edit) {
case ' ':
++common_;
FlushEdits();
hunk_.push_back(std::make_pair(' ', line));
break;
case '-':
++removes_;
hunk_removes_.push_back(std::make_pair('-', line));
break;
case '+':
++adds_;
hunk_adds_.push_back(std::make_pair('+', line));
break;
} */ ( edit ) { |
| 1336: case ' ' : |
| 1337: common_ ; |
1338: FlushEdits/* FlushEdits() */ ( ) ; |
| 1339: hunk_ . push_back ( std :: make_pair ( ' ' , line ) ) ; |
| 1340: break ; |
| 1341: case '-' : |
| 1342: removes_ ; |
| 1343: hunk_removes_ . push_back ( std :: make_pair ( '-' , line ) ) ; |
| 1344: break ; |
| 1345: case '+' : |
| 1346: adds_ ; |
| 1347: hunk_adds_ . push_back ( std :: make_pair ( '+' , line ) ) ; |
| 1348: break ; |
| 1349: } |
| 1350: } |
| 1351: |
| 1352: void PrintTo ( std :: ostream * os ) {/*
PrintHeader(os);
FlushEdits();
for (std::list<std::pair<char, const char*> >::const_iterator it =
hunk_.begin();
it != hunk_.end(); ++it) {
*os << it->first << it->second << "\n";
}
*/ |
1353: PrintHeader/* PrintHeader(os) */ ( os ) ; |
1354: FlushEdits/* FlushEdits() */ ( ) ; |
1355: for/* for (std::list<std::pair<char, const char*> >::const_iterator it =
hunk_.begin();
it != hunk_.end(); ++it) {
*os << it->first << it->second << "\n";
} */ ( std :: list < std :: pair < char , const char * > > :: const_iterator it = |
| 1356: hunk_ . begin ( ) ; |
| 1357: it != hunk_ . end ( ) ; ++ it ) {/*
*os << it->first << it->second << "\n";
*/ |
1358: */* *os << it->first << it->second << "\n" */ os << it -> first << it -> second << "\n" ; |
| 1359: } |
| 1360: } |
| 1361: |
| 1362: bool has_edits ( ) const { return removes_ ; } |
| 1363: |
| 1364: private : |
| 1365: void FlushEdits ( ) {/*
hunk_.splice(hunk_.end(), hunk_removes_);
hunk_.splice(hunk_.end(), hunk_adds_);
*/ |
| 1366: hunk_ . splice ( hunk_ . end ( ) , hunk_removes_ ) ; |
| 1367: hunk_ . splice ( hunk_ . end ( ) , hunk_adds_ ) ; |
| 1368: } |
| 1369: |
| 1370: |
| 1371: |
| 1372: |
| 1373: |
| 1374: void PrintHeader ( std :: ostream * ss ) const {/*
*ss << "@@ ";
if (removes_) {
*ss << "-" << left_start_ << "," << (removes_ + common_);
}
if (removes_ && adds_) {
*ss << " ";
}
if (adds_) {
*ss << "+" << right_start_ << "," << (adds_ + common_);
}
*ss << " @@\n";
*/ |
| 1375: ss << "@@ " ; |
1376: if/* if (removes_) {
*ss << "-" << left_start_ << "," << (removes_ + common_);
} */ removes_ ) {/*
*ss << "-" << left_start_ << "," << (removes_ + common_);
*/ |
1377: */* *ss << "-" << left_start_ << "," << (removes_ + common_) */ ss << "-" << left_start_ << "," << ( removes_ + common_ ) ; |
| 1378: } |
1379: if/* if (removes_ && adds_) {
*ss << " ";
} */ removes_ adds_ ) |
| 1380: ss << " " ; |
| 1381: } |
1382: if/* if (adds_) {
*ss << "+" << right_start_ << "," << (adds_ + common_);
} */ adds_ ) {/*
*ss << "+" << right_start_ << "," << (adds_ + common_);
*/ |
1383: */* *ss << "+" << right_start_ << "," << (adds_ + common_) */ ss << "+" << right_start_ << "," << ( adds_ + common_ ) ; |
| 1384: } |
| 1385: ss << " @@\n" ; |
| 1386: } |
| 1387: |
| 1388: size_t left_start_ , right_start_ ; |
| 1389: size_t adds_ , removes_ , common_ ; |
| 1390: std :: list < std :: pair < char , const char * > > hunk_ , hunk_adds_ , hunk_removes_ ; |
| 1391: } ; |
| 1392: |
| 1393: } |
| 1394: |
| 1395: |
| 1396: |
| 1397: |
| 1398: |
| 1399: |
| 1400: |
| 1401: |
| 1402: std :: string CreateUnifiedDiff ( const std :: vector < std :: string > & left , |
| 1403: const std :: vector < std :: string > & right , |
| 1404: size_t context ) { |
| 1405: const std :: vector < EditType > edits = CalculateOptimalEdits ( left , right ) ; |
| 1406: |
| 1407: size_t l_i = 0 , r_i = 0 , edit_i = 0 ; |
| 1408: std :: stringstream ss ; |
1409: while/* while (edit_i < edits.size()) {
// Find first edit.
while (edit_i < edits.size() && edits[edit_i] == kMatch) {
++l_i;
++r_i;
++edit_i;
}
// Find the first line to include in the hunk.
const size_t prefix_context = std::min(l_i, context);
Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1);
for (size_t i = prefix_context; i > 0; --i) {
hunk.PushLine(' ', left[l_i - i].c_str());
}
// Iterate the edits until we found enough suffix for the hunk or the input
// is over.
size_t n_suffix = 0;
for (; edit_i < edits.size(); ++edit_i) {
if (n_suffix >= context) {
// Continue only if the next hunk is very close.
auto it = edits.begin() + static_cast<int>(edit_i);
while (it != edits.end() && *it == kMatch) ++it;
if (it == edits.end() ||
static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
}
}
EditType edit = edits[edit_i];
// Reset count when a non match is found.
n_suffix = edit == kMatch ? n_suffix + 1 : 0;
if (edit == kMatch || edit == kRemove || edit == kReplace) {
hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
}
if (edit == kAdd || edit == kReplace) {
hunk.PushLine('+', right[r_i].c_str());
}
// Advance indices, depending on edit type.
l_i += edit != kAdd;
r_i += edit != kRemove;
}
if (!hunk.has_edits()) {
// We are done. We don't want this hunk.
break;
}
hunk.PrintTo(&ss);
} */ edit_i < edits . size ( ) ) {/*
// Find first edit.
while (edit_i < edits.size() && edits[edit_i] == kMatch) {
++l_i;
++r_i;
++edit_i;
}
// Find the first line to include in the hunk.
const size_t prefix_context = std::min(l_i, context);
Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1);
for (size_t i = prefix_context; i > 0; --i) {
hunk.PushLine(' ', left[l_i - i].c_str());
}
// Iterate the edits until we found enough suffix for the hunk or the input
// is over.
size_t n_suffix = 0;
for (; edit_i < edits.size(); ++edit_i) {
if (n_suffix >= context) {
// Continue only if the next hunk is very close.
auto it = edits.begin() + static_cast<int>(edit_i);
while (it != edits.end() && *it == kMatch) ++it;
if (it == edits.end() ||
static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
}
}
EditType edit = edits[edit_i];
// Reset count when a non match is found.
n_suffix = edit == kMatch ? n_suffix + 1 : 0;
if (edit == kMatch || edit == kRemove || edit == kReplace) {
hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
}
if (edit == kAdd || edit == kReplace) {
hunk.PushLine('+', right[r_i].c_str());
}
// Advance indices, depending on edit type.
l_i += edit != kAdd;
r_i += edit != kRemove;
}
if (!hunk.has_edits()) {
// We are done. We don't want this hunk.
break;
}
hunk.PrintTo(&ss);
*/ |
| 1410: |
1411: while/* while (edit_i < edits.size() && edits[edit_i] == kMatch) {
++l_i;
++r_i;
++edit_i;
} */ (truefalsetruefalsetruefalse edit_i < edits . size ( ) [ edit_i ] == kMatch ) {/*
++l_i;
++r_i;
++edit_i;
*/ |
| 1412: l_i ; |
| 1413: r_i ; |
| 1414: edit_i ; |
| 1415: } |
| 1416: |
| 1417: |
| 1418: const size_t prefix_context = std :: min ( l_i , context ) ; |
| 1419: Hunk hunk ( l_i - prefix_context + 1 , r_i - prefix_context + 1 ) ; |
1420: for/* for (size_t i = prefix_context; i > 0; --i) {
hunk.PushLine(' ', left[l_i - i].c_str());
} */ ( size_t i = prefix_context ; i > 0 ; -- i ) {/*
hunk.PushLine(' ', left[l_i - i].c_str());
*/ |
1421: hunk/* hunk.PushLine(' ', left[l_i - i].c_str()) */ . PushLine ( ' ' , left [ l_i - i ] . c_str ( ) ) ; |
| 1422: } |
| 1423: |
| 1424: |
| 1425: |
| 1426: size_t n_suffix = 0 ; |
1427: for/* for (; edit_i < edits.size(); ++edit_i) {
if (n_suffix >= context) {
// Continue only if the next hunk is very close.
auto it = edits.begin() + static_cast<int>(edit_i);
while (it != edits.end() && *it == kMatch) ++it;
if (it == edits.end() ||
static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
}
}
EditType edit = edits[edit_i];
// Reset count when a non match is found.
n_suffix = edit == kMatch ? n_suffix + 1 : 0;
if (edit == kMatch || edit == kRemove || edit == kReplace) {
hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
}
if (edit == kAdd || edit == kReplace) {
hunk.PushLine('+', right[r_i].c_str());
}
// Advance indices, depending on edit type.
l_i += edit != kAdd;
r_i += edit != kRemove;
} */ ( ; edit_i < edits . size ( ) ; ++ edit_i ) {/*
if (n_suffix >= context) {
// Continue only if the next hunk is very close.
auto it = edits.begin() + static_cast<int>(edit_i);
while (it != edits.end() && *it == kMatch) ++it;
if (it == edits.end() ||
static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
}
}
EditType edit = edits[edit_i];
// Reset count when a non match is found.
n_suffix = edit == kMatch ? n_suffix + 1 : 0;
if (edit == kMatch || edit == kRemove || edit == kReplace) {
hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
}
if (edit == kAdd || edit == kReplace) {
hunk.PushLine('+', right[r_i].c_str());
}
// Advance indices, depending on edit type.
l_i += edit != kAdd;
r_i += edit != kRemove;
*/ |
1428: if/* if (n_suffix >= context) {
// Continue only if the next hunk is very close.
auto it = edits.begin() + static_cast<int>(edit_i);
while (it != edits.end() && *it == kMatch) ++it;
if (it == edits.end() ||
static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
}
} */ n_suffix >= context ) {/*
// Continue only if the next hunk is very close.
auto it = edits.begin() + static_cast<int>(edit_i);
while (it != edits.end() && *it == kMatch) ++it;
if (it == edits.end() ||
static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
}
*/ |
| 1429: |
| 1430: auto it = edits . begin ( ) + static_cast < int > ( edit_i ) ; |
1431: while/* while (it != edits.end() && *it == kMatch) ++it */ (truefalsetruefalsetruefalse it != edits . end ( ) it == kMatch ) ++ it ; |
1432: if/* if (it == edits.end() ||
static_cast<size_t>(it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
} */ (truefalsetruefalsetruefalse it == edits . end ( ) |
| 1433: < size_t > ( it - edits . begin ( ) ) - edit_i >= context ) { |
| 1434: |
| 1435: break ; |
| 1436: } |
| 1437: } |
| 1438: |
| 1439: EditType edit = edits [ edit_i ] ; |
| 1440: |
1441: n_suffix/* n_suffix = edit == kMatch ? n_suffix + 1 : 0 */ = == kMatch ? n_suffix + 1 : 0 ; |
| 1442: |
1443: if/* if (edit == kMatch || edit == kRemove || edit == kReplace) {
hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
} */ (truefalsetruefalsetruefalsetruefalsetruefalse edit == kMatch == kRemove == kReplace ) {/*
hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
*/ |
1444: hunk/* hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str()) */ . PushLine edit == kMatch ? ' ' : '-' , left [ l_i ] . c_str ( ) ) ; |
| 1445: } |
1446: if/* if (edit == kAdd || edit == kReplace) {
hunk.PushLine('+', right[r_i].c_str());
} */ (truefalsetruefalsetruefalse edit == kAdd == kReplace ) {/*
hunk.PushLine('+', right[r_i].c_str());
*/ |
1447: hunk/* hunk.PushLine('+', right[r_i].c_str()) */ . PushLine ( '+' , right [ r_i ] . c_str ( ) ) ; |
| 1448: } |
| 1449: |
| 1450: |
1451: l_i/* l_i += edit != kAdd */ += != kAdd ; |
1452: r_i/* r_i += edit != kRemove */ += != kRemove ; |
| 1453: } |
| 1454: |
1455: if/* if (!hunk.has_edits()) {
// We are done. We don't want this hunk.
break;
} */ (truefalse!!hunk.has_edits() ! hunk . has_edits ( ) ) { |
| 1456: |
| 1457: break ; |
| 1458: } |
| 1459: |
1460: hunk/* hunk.PrintTo(&ss) */ . PrintTo ( & ss ) ; |
| 1461: } |
| 1462: return ss . str ( ) ; |
| 1463: } |
| 1464: |
| 1465: } |
| 1466: |
| 1467: namespace { |
| 1468: |
| 1469: |
| 1470: |
| 1471: |
| 1472: std :: vector < std :: string > SplitEscapedString ( const std :: string & str ) { |
| 1473: std :: vector < std :: string > lines ; |
| 1474: size_t start = 0 , end = str . size ( ) ; |
1475: if/* if (end > 2 && str[0] == '"' && str[end - 1] == '"') {
++start;
--end;
} */ (truefalsetruefalsetruefalsetruefalsetruefalse end > 2 [ 0 ] == '"' [ end - 1 ] == '"' ) |
| 1476: start ; |
| 1477: end ; |
| 1478: } |
| 1479: bool escaped = false ; |
1480: for/* for (size_t i = start; i + 1 < end; ++i) {
if (escaped) {
escaped = false;
if (str[i] == 'n') {
lines.push_back(str.substr(start, i - start - 1));
start = i + 1;
}
} else {
escaped = str[i] == '\\';
}
} */ ( size_t i = start ; i + 1 < end ; ++ i ) {/*
if (escaped) {
escaped = false;
if (str[i] == 'n') {
lines.push_back(str.substr(start, i - start - 1));
start = i + 1;
}
} else {
escaped = str[i] == '\\';
}
*/ |
1481: if/* if (escaped) {
escaped = false;
if (str[i] == 'n') {
lines.push_back(str.substr(start, i - start - 1));
start = i + 1;
}
} else {
escaped = str[i] == '\\';
} */ escaped ) {/*
escaped = false;
if (str[i] == 'n') {
lines.push_back(str.substr(start, i - start - 1));
start = i + 1;
}
*/ |
1482: escaped/* escaped = false */ = false ; |
1483: if/* if (str[i] == 'n') {
lines.push_back(str.substr(start, i - start - 1));
start = i + 1;
} */ str [ i ] == 'n' ) {/*
lines.push_back(str.substr(start, i - start - 1));
start = i + 1;
*/ |
| 1484: lines . push_back ( str . substr ( start , i - start - 1 ) ) ; |
| 1485: = i + 1 ; |
| 1486: } |
| 1487: } else {/*
escaped = str[i] == '\\';
*/ |
1488: escaped/* escaped = str[i] == '\\' */ = [ i ] == '\\' ; |
| 1489: } |
| 1490: } |
| 1491: lines . push_back ( str . substr ( start , end - start ) ) ; |
| 1492: return lines ; |
| 1493: } |
| 1494: |
| 1495: } |
| 1496: |
| 1497: |
| 1498: |
| 1499: |
| 1500: |
| 1501: |
| 1502: |
| 1503: |
| 1504: |
| 1505: |
| 1506: |
| 1507: |
| 1508: |
| 1509: |
| 1510: |
| 1511: |
| 1512: AssertionResult EqFailure ( const char * lhs_expression , |
| 1513: const char * rhs_expression , |
| 1514: const std :: string & lhs_value , |
| 1515: const std :: string & rhs_value , |
| 1516: bool ignoring_case ) { |
| 1517: Message msg ; |
1518: msg/* msg << "Expected equality of these values:" */ << "Expected equality of these values:" ; |
1519: msg/* msg << "\n " << lhs_expression */ << "\n " << lhs_expression ; |
1520: if/* if (lhs_value != lhs_expression) {
msg << "\n Which is: " << lhs_value;
} */ lhs_value != lhs_expression ) {/*
msg << "\n Which is: " << lhs_value;
*/ |
1521: msg/* msg << "\n Which is: " << lhs_value */ << "\n Which is: " << lhs_value ; |
| 1522: } |
1523: msg/* msg << "\n " << rhs_expression */ << "\n " << rhs_expression ; |
1524: if/* if (rhs_value != rhs_expression) {
msg << "\n Which is: " << rhs_value;
} */ rhs_value != rhs_expression ) {/*
msg << "\n Which is: " << rhs_value;
*/ |
1525: msg/* msg << "\n Which is: " << rhs_value */ << "\n Which is: " << rhs_value ; |
| 1526: } |
| 1527: |
1528: if/* if (ignoring_case) {
msg << "\nIgnoring case";
} */ ignoring_case ) {/*
msg << "\nIgnoring case";
*/ |
1529: msg/* msg << "\nIgnoring case" */ << "\nIgnoring case" ; |
| 1530: } |
| 1531: |
1532: if/* if (!lhs_value.empty() && !rhs_value.empty()) {
const std::vector<std::string> lhs_lines =
SplitEscapedString(lhs_value);
const std::vector<std::string> rhs_lines =
SplitEscapedString(rhs_value);
if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {
msg << "\nWith diff:\n"
<< edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);
}
} */ (!!lhs_value.empty()truefalsetruefalse ! lhs_value . empty ( ) rhs_value . empty ( ) ) {/*
const std::vector<std::string> lhs_lines =
SplitEscapedString(lhs_value);
const std::vector<std::string> rhs_lines =
SplitEscapedString(rhs_value);
if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {
msg << "\nWith diff:\n"
<< edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);
}
*/ |
| 1533: const std :: vector < std :: string > lhs_lines = |
| 1534: SplitEscapedString ( lhs_value ) ; |
| 1535: const std :: vector < std :: string > rhs_lines = |
| 1536: SplitEscapedString ( rhs_value ) ; |
1537: if/* if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {
msg << "\nWith diff:\n"
<< edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);
} */ (truefalsetruefalsetruefalse lhs_lines . size ( ) > 1 . size ( ) > 1 ) {/*
msg << "\nWith diff:\n"
<< edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);
*/ |
| 1538: msg << "\nWith diff:\n" |
| 1539: << edit_distance :: CreateUnifiedDiff ( lhs_lines , rhs_lines ) ; |
| 1540: } |
| 1541: } |
| 1542: |
| 1543: return AssertionFailure ( ) << msg ; |
| 1544: } |
| 1545: |
| 1546: |
| 1547: std :: string GetBoolAssertionFailureMessage ( |
| 1548: const AssertionResult & assertion_result , |
| 1549: const char * expression_text , |
| 1550: const char * actual_predicate_value , |
| 1551: const char * expected_predicate_value ) { |
| 1552: const char * actual_message = assertion_result . message ( ) ; |
| 1553: Message msg ; |
1554: msg/* msg << "Value of: " << expression_text
<< "\n Actual: " << actual_predicate_value */ << "Value of: " << expression_text |
| 1555: << "\n Actual: " << actual_predicate_value ; |
1556: if/* if (actual_message[0] != '\0')
msg << " (" << actual_message << ")" */ actual_message [ 0 ] != '\0' ) |
| 1557: msg << " (" << actual_message << ")" ; |
1558: msg/* msg << "\nExpected: " << expected_predicate_value */ << "\nExpected: " << expected_predicate_value ; |
| 1559: return msg . GetString ( ) ; |
| 1560: } |
| 1561: |
| 1562: |
| 1563: AssertionResult DoubleNearPredFormat ( const char * expr1 , |
| 1564: const char * expr2 , |
| 1565: const char * abs_error_expr , |
| 1566: double val1 , |
| 1567: double val2 , |
| 1568: double abs_error ) { |
| 1569: const double diff = fabs ( val1 - val2 ) ; |
| 1570: if diff <= abs_error ) return AssertionSuccess ( ) ; |
| 1571: |
| 1572: |
| 1573: const double min_abs = std :: min ( fabs ( val1 ) , fabs ( val2 ) ) ; |
| 1574: |
| 1575: const double epsilon = |
| 1576: nextafter ( min_abs , std :: numeric_limits < double > :: infinity ( ) ) - min_abs ; |
| 1577: |
| 1578: |
| 1579: |
| 1580: |
| 1581: |
| 1582: |
| 1583: if (!!(std::isnan)(val1)truefalsetruefalsetruefalsetruefalsetruefalsetruefalse ! ( std :: isnan ) ( val1 ) ( std :: isnan ) ( val2 ) > 0 |
| 1584: < epsilon ) { |
| 1585: return AssertionFailure ( ) |
| 1586: << "The difference between " << expr1 << " and " << expr2 << " is " |
| 1587: << diff << ", where\n" |
| 1588: << expr1 << " evaluates to " << val1 << ",\n" |
| 1589: << expr2 << " evaluates to " << val2 << ".\nThe abs_error parameter " |
| 1590: << abs_error_expr << " evaluates to " << abs_error |
| 1591: << " which is smaller than the minimum distance between doubles for " |
| 1592: "numbers of this magnitude which is " |
| 1593: << epsilon |
| 1594: << ", thus making this EXPECT_NEAR check equivalent to " |
| 1595: "EXPECT_EQUAL. Consider using EXPECT_DOUBLE_EQ instead." ; |
| 1596: } |
| 1597: return AssertionFailure ( ) |
| 1598: << "The difference between " << expr1 << " and " << expr2 |
| 1599: << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n" |
| 1600: << expr1 << " evaluates to " << val1 << ",\n" |
| 1601: << expr2 << " evaluates to " << val2 << ", and\n" |
| 1602: << abs_error_expr << " evaluates to " << abs_error << "." ; |
| 1603: } |
| 1604: |
| 1605: |
| 1606: |
| 1607: template < typename RawType > |
| 1608: AssertionResult FloatingPointLE ( const char * expr1 , |
| 1609: const char * expr2 , |
| 1610: RawType val1 , |
| 1611: RawType val2 ) { |
| 1612: |
| 1613: if val1 < val2 ) { |
| 1614: return AssertionSuccess ( ) ; |
| 1615: } |
| 1616: |
| 1617: |
| 1618: const FloatingPoint < RawType > lhs ( val1 ) , rhs ( val2 ) ; |
| 1619: if lhs . AlmostEquals ( rhs ) ) { |
| 1620: return AssertionSuccess ( ) ; |
| 1621: } |
| 1622: |
| 1623: |
| 1624: |
| 1625: |
| 1626: |
| 1627: :: std :: stringstream val1_ss ; |
1628: val1_ss/* val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
<< val1 */ << std :: setprecision ( std :: numeric_limits < RawType > :: digits10 + 2 ) |
| 1629: << val1 ; |
| 1630: |
| 1631: :: std :: stringstream val2_ss ; |
1632: val2_ss/* val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
<< val2 */ << std :: setprecision ( std :: numeric_limits < RawType > :: digits10 + 2 ) |
| 1633: << val2 ; |
| 1634: |
| 1635: return AssertionFailure ( ) |
| 1636: << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" |
| 1637: << " Actual: " << StringStreamToString ( & val1_ss ) << " vs " |
| 1638: << StringStreamToString ( & val2_ss ) ; |
| 1639: } |
| 1640: |
| 1641: } |
| 1642: |
| 1643: |
| 1644: |
| 1645: AssertionResult FloatLE ( const char * expr1 , const char * expr2 , |
| 1646: float val1 , float val2 ) { |
| 1647: return internal :: FloatingPointLE < float > ( expr1 , expr2 , val1 , val2 ) ; |
| 1648: } |
| 1649: |
| 1650: |
| 1651: |
| 1652: AssertionResult DoubleLE ( const char * expr1 , const char * expr2 , |
| 1653: double val1 , double val2 ) { |
| 1654: return internal :: FloatingPointLE < double > ( expr1 , expr2 , val1 , val2 ) ; |
| 1655: } |
| 1656: |
| 1657: namespace internal { |
| 1658: |
| 1659: |
| 1660: AssertionResult CmpHelperSTREQ ( const char * lhs_expression , |
| 1661: const char * rhs_expression , |
| 1662: const char * lhs , |
| 1663: const char * rhs ) { |
| 1664: if String :: CStringEquals ( lhs , rhs ) ) { |
| 1665: return AssertionSuccess ( ) ; |
| 1666: } |
| 1667: |
| 1668: return EqFailure ( lhs_expression , |
| 1669: rhs_expression , |
| 1670: PrintToString ( lhs ) , |
| 1671: PrintToString ( rhs ) , |
| 1672: false ) ; |
| 1673: } |
| 1674: |
| 1675: |
| 1676: AssertionResult CmpHelperSTRCASEEQ ( const char * lhs_expression , |
| 1677: const char * rhs_expression , |
| 1678: const char * lhs , |
| 1679: const char * rhs ) { |
| 1680: if String :: CaseInsensitiveCStringEquals ( lhs , rhs ) ) { |
| 1681: return AssertionSuccess ( ) ; |
| 1682: } |
| 1683: |
| 1684: return EqFailure ( lhs_expression , |
| 1685: rhs_expression , |
| 1686: PrintToString ( lhs ) , |
| 1687: PrintToString ( rhs ) , |
| 1688: true ) ; |
| 1689: } |
| 1690: |
| 1691: |
| 1692: AssertionResult CmpHelperSTRNE ( const char * s1_expression , |
| 1693: const char * s2_expression , |
| 1694: const char * s1 , |
| 1695: const char * s2 ) { |
| 1696: if (truefalse!!String::CStringEquals(s1, s2) ! String :: CStringEquals ( s1 , s2 ) ) { |
| 1697: return AssertionSuccess ( ) ; |
| 1698: } else { |
| 1699: return AssertionFailure ( ) << "Expected: (" << s1_expression << ") != (" |
| 1700: << s2_expression << "), actual: \"" |
| 1701: << s1 << "\" vs \"" << s2 << "\"" ; |
| 1702: } |
| 1703: } |
| 1704: |
| 1705: |
| 1706: AssertionResult CmpHelperSTRCASENE ( const char * s1_expression , |
| 1707: const char * s2_expression , |
| 1708: const char * s1 , |
| 1709: const char * s2 ) { |
| 1710: if (truefalse!!String::CaseInsensitiveCStringEquals(s1, s2) ! String :: CaseInsensitiveCStringEquals ( s1 , s2 ) ) { |
| 1711: return AssertionSuccess ( ) ; |
| 1712: } else { |
| 1713: return AssertionFailure ( ) |
| 1714: << "Expected: (" << s1_expression << ") != (" |
| 1715: << s2_expression << ") (ignoring case), actual: \"" |
| 1716: << s1 << "\" vs \"" << s2 << "\"" ; |
| 1717: } |
| 1718: } |
| 1719: |
| 1720: } |
| 1721: |
| 1722: namespace { |
| 1723: |
| 1724: |
| 1725: |
| 1726: |
| 1727: |
| 1728: |
| 1729: |
| 1730: bool IsSubstringPred ( const char * needle , const char * haystack ) { |
| 1731: if (truefalsetruefalsetruefalse needle == nullptr == nullptr ) return == haystack ; |
| 1732: |
| 1733: return ( haystack , needle ) != nullptr ; |
| 1734: } |
| 1735: |
| 1736: bool IsSubstringPred ( const wchar_t * needle , const wchar_t * haystack ) { |
| 1737: if (truefalsetruefalsetruefalse needle == nullptr == nullptr ) return == haystack ; |
| 1738: |
| 1739: return ( haystack , needle ) != nullptr ; |
| 1740: } |
| 1741: |
| 1742: |
| 1743: template < typename StringType > |
| 1744: bool IsSubstringPred ( const StringType & needle , |
| 1745: const StringType & haystack ) { |
| 1746: return haystack . find ( needle ) != StringType :: npos ; |
| 1747: } |
| 1748: |
| 1749: |
| 1750: |
| 1751: |
| 1752: |
| 1753: template < typename StringType > |
| 1754: AssertionResult IsSubstringImpl ( |
| 1755: bool expected_to_be_substring , |
| 1756: const char * needle_expr , const char * haystack_expr , |
| 1757: const StringType & needle , const StringType & haystack ) { |
| 1758: if IsSubstringPred ( needle , haystack ) == expected_to_be_substring ) |
| 1759: return AssertionSuccess ( ) ; |
| 1760: |
| 1761: const bool is_wide_string = ( needle [ 0 ] ) > 1 ; |
| 1762: const char * const begin_string_quote = is_wide_string ? "L\"" : "\"" ; |
| 1763: return AssertionFailure ( ) |
| 1764: << "Value of: " << needle_expr << "\n" |
| 1765: << " Actual: " << begin_string_quote << needle << "\"\n" |
| 1766: << "Expected: " << ( expected_to_be_substring ? "" : "not " ) |
| 1767: << "a substring of " << haystack_expr << "\n" |
| 1768: << "Which is: " << begin_string_quote << haystack << "\"" ; |
| 1769: } |
| 1770: |
| 1771: } |
| 1772: |
| 1773: |
| 1774: |
| 1775: |
| 1776: |
| 1777: AssertionResult IsSubstring ( |
| 1778: const char * needle_expr , const char * haystack_expr , |
| 1779: const char * needle , const char * haystack ) { |
| 1780: return IsSubstringImpl ( true , needle_expr , haystack_expr , needle , haystack ) ; |
| 1781: } |
| 1782: |
| 1783: AssertionResult IsSubstring ( |
| 1784: const char * needle_expr , const char * haystack_expr , |
| 1785: const wchar_t * needle , const wchar_t * haystack ) { |
| 1786: return IsSubstringImpl ( true , needle_expr , haystack_expr , needle , haystack ) ; |
| 1787: } |
| 1788: |
| 1789: AssertionResult IsNotSubstring ( |
| 1790: const char * needle_expr , const char * haystack_expr , |
| 1791: const char * needle , const char * haystack ) { |
| 1792: return IsSubstringImpl ( false , needle_expr , haystack_expr , needle , haystack ) ; |
| 1793: } |
| 1794: |
| 1795: AssertionResult IsNotSubstring ( |
| 1796: const char * needle_expr , const char * haystack_expr , |
| 1797: const wchar_t * needle , const wchar_t * haystack ) { |
| 1798: return IsSubstringImpl ( false , needle_expr , haystack_expr , needle , haystack ) ; |
| 1799: } |
| 1800: |
| 1801: AssertionResult IsSubstring ( |
| 1802: const char * needle_expr , const char * haystack_expr , |
| 1803: const :: std :: string & needle , const :: std :: string & haystack ) { |
| 1804: return IsSubstringImpl ( true , needle_expr , haystack_expr , needle , haystack ) ; |
| 1805: } |
| 1806: |
| 1807: AssertionResult IsNotSubstring ( |
| 1808: const char * needle_expr , const char * haystack_expr , |
| 1809: const :: std :: string & needle , const :: std :: string & haystack ) { |
| 1810: return IsSubstringImpl ( false , needle_expr , haystack_expr , needle , haystack ) ; |
| 1811: } |
| 1812: |
| 1813: # if GTEST_HAS_STD_WSTRING |
| 1814: AssertionResult IsSubstring ( |
| 1815: const char * needle_expr , const char * haystack_expr , |
| 1816: const :: std :: wstring & needle , const :: std :: wstring & haystack ) { |
| 1817: return IsSubstringImpl ( true , needle_expr , haystack_expr , needle , haystack ) ; |
| 1818: } |
| 1819: |
| 1820: AssertionResult IsNotSubstring ( |
| 1821: const char * needle_expr , const char * haystack_expr , |
| 1822: const :: std :: wstring & needle , const :: std :: wstring & haystack ) { |
| 1823: return IsSubstringImpl ( false , needle_expr , haystack_expr , needle , haystack ) ; |
| 1824: } |
| 1825: # endif |
| 1826: |
| 1827: namespace internal { |
| 1828: |
| 1829: # if GTEST_OS_WINDOWS |
| 1830: |
| 1831: namespace { |
| 1832: |
| 1833: |
| 1834: AssertionResult HRESULTFailureHelper ( const char * expr , |
| 1835: const char * expected , |
| 1836: long hr ) { |
| 1837: # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_WINDOWS_TV_TITLE |
| 1838: |
| 1839: |
| 1840: const char error_text [ ] = "" ; |
| 1841: |
| 1842: # else |
| 1843: |
| 1844: |
| 1845: |
| 1846: |
| 1847: const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | |
| 1848: FORMAT_MESSAGE_IGNORE_INSERTS ; |
| 1849: const DWORD kBufSize = 4096 ; |
| 1850: |
| 1851: char error_text [ kBufSize ] = { '\0' } ; |
| 1852: DWORD message_length = :: FormatMessageA ( kFlags , |
| 1853: 0 , |
| 1854: static_cast < DWORD > ( hr ) , |
| 1855: 0 , |
| 1856: error_text , |
| 1857: kBufSize , |
| 1858: nullptr ) ; |
| 1859: |
| 1860: for ( ; message_length && IsSpace ( error_text [ message_length - 1 ] ) ; |
| 1861: -- message_length ) { |
| 1862: error_text [ message_length - 1 ] = '\0' ; |
| 1863: } |
| 1864: |
| 1865: # endif |
| 1866: |
| 1867: const std :: string error_hex ( "0x" + String :: FormatHexInt ( hr ) ) ; |
| 1868: return :: testing :: AssertionFailure ( ) |
| 1869: << "Expected: " << expr << " " << expected << ".\n" |
| 1870: << " Actual: " << error_hex << " " << error_text << "\n" ; |
| 1871: } |
| 1872: |
| 1873: } |
| 1874: |
| 1875: AssertionResult IsHRESULTSuccess ( const char * expr , long hr ) { |
| 1876: if ( SUCCEEDED ( hr ) ) { |
| 1877: return AssertionSuccess ( ) ; |
| 1878: } |
| 1879: return HRESULTFailureHelper ( expr , "succeeds" , hr ) ; |
| 1880: } |
| 1881: |
| 1882: AssertionResult IsHRESULTFailure ( const char * expr , long hr ) { |
| 1883: if ( FAILED ( hr ) ) { |
| 1884: return AssertionSuccess ( ) ; |
| 1885: } |
| 1886: return HRESULTFailureHelper ( expr , "fails" , hr ) ; |
| 1887: } |
| 1888: |
| 1889: # endif |
| 1890: |
| 1891: |
| 1892: |
| 1893: |
| 1894: |
| 1895: |
| 1896: |
| 1897: |
| 1898: |
| 1899: |
| 1900: |
| 1901: |
| 1902: |
| 1903: |
| 1904: constexpr uint32_t kMaxCodePoint1 = ( static_cast < uint32_t > ( 1 ) << 7 ) - 1 ; |
| 1905: |
| 1906: |
| 1907: constexpr uint32_t kMaxCodePoint2 = ( static_cast < uint32_t > ( 1 ) << ( 5 + 6 ) ) - 1 ; |
| 1908: |
| 1909: |
| 1910: constexpr uint32_t kMaxCodePoint3 = ( static_cast < uint32_t > ( 1 ) << ( 4 + 2 * 6 ) ) - 1 ; |
| 1911: |
| 1912: |
| 1913: constexpr uint32_t kMaxCodePoint4 = ( static_cast < uint32_t > ( 1 ) << ( 3 + 3 * 6 ) ) - 1 ; |
| 1914: |
| 1915: |
| 1916: |
| 1917: |
| 1918: inline uint32_t ChopLowBits ( uint32_t * bits , int n ) { |
| 1919: const uint32_t low_bits = bits &|/* & ((static_cast<uint32_t>(1) << n) - 1) */ ( ( static_cast < uint32_t > ( 1 ) << n ) - 1 ) ; |
| 1920: bits >>= n ; |
| 1921: return low_bits ; |
| 1922: } |
| 1923: |
| 1924: |
| 1925: |
| 1926: |
| 1927: |
| 1928: |
| 1929: |
| 1930: std :: string CodePointToUtf8 ( uint32_t code_point ) { |
| 1931: if code_point > kMaxCodePoint4 ) { |
| 1932: return "(Invalid Unicode 0x" + String :: FormatHexUInt32 ( code_point ) + ")" ; |
| 1933: } |
| 1934: |
| 1935: char str [ 5 ] ; |
1936: if/* if (code_point <= kMaxCodePoint1) {
str[1] = '\0';
str[0] = static_cast<char>(code_point); // 0xxxxxxx
} else if (code_point <= kMaxCodePoint2) {
str[2] = '\0';
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xC0 | code_point); // 110xxxxx
} else if (code_point <= kMaxCodePoint3) {
str[3] = '\0';
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xE0 | code_point); // 1110xxxx
} else { // code_point <= kMaxCodePoint4
str[4] = '\0';
str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xF0 | code_point); // 11110xxx
} */ code_point <= kMaxCodePoint1 ) {/*
str[1] = '\0';
str[0] = static_cast<char>(code_point); // 0xxxxxxx
*/ |
| 1937: [ 1 ] = '\0' ; |
1938: str/* str[0] = static_cast<char>(code_point) */ [ 0 ] = static_cast < char > ( code_point ) ; |
| 1939: } else if/* if (code_point <= kMaxCodePoint2) {
str[2] = '\0';
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xC0 | code_point); // 110xxxxx
} else if (code_point <= kMaxCodePoint3) {
str[3] = '\0';
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xE0 | code_point); // 1110xxxx
} else { // code_point <= kMaxCodePoint4
str[4] = '\0';
str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xF0 | code_point); // 11110xxx
} */ code_point <= kMaxCodePoint2 ) {/*
str[2] = '\0';
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xC0 | code_point); // 110xxxxx
*/ |
| 1940: [ 2 ] = '\0' ; |
1941: str/* str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)) */ [ 1 ] = static_cast < char > 0x80 |&/* | ChopLowBits(&code_point, 6) */ ChopLowBits ( & code_point , 6 ) ) ; |
1942: str/* str[0] = static_cast<char>(0xC0 | code_point) */ [ 0 ] = static_cast < char > 0xC0 code_point ) ; |
| 1943: } else if/* if (code_point <= kMaxCodePoint3) {
str[3] = '\0';
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xE0 | code_point); // 1110xxxx
} else { // code_point <= kMaxCodePoint4
str[4] = '\0';
str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xF0 | code_point); // 11110xxx
} */ code_point <= kMaxCodePoint3 ) {/*
str[3] = '\0';
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xE0 | code_point); // 1110xxxx
*/ |
| 1944: [ 3 ] = '\0' ; |
1945: str/* str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)) */ [ 2 ] = static_cast < char > 0x80 |&/* | ChopLowBits(&code_point, 6) */ ChopLowBits ( & code_point , 6 ) ) ; |
1946: str/* str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)) */ [ 1 ] = static_cast < char > 0x80 |&/* | ChopLowBits(&code_point, 6) */ ChopLowBits ( & code_point , 6 ) ) ; |
1947: str/* str[0] = static_cast<char>(0xE0 | code_point) */ [ 0 ] = static_cast < char > 0xE0 code_point ) ; |
| 1948: } else {/* // code_point <= kMaxCodePoint4
str[4] = '\0';
str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xF0 | code_point); // 11110xxx
*/ |
| 1949: [ 4 ] = '\0' ; |
1950: str/* str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)) */ [ 3 ] = static_cast < char > 0x80 |&/* | ChopLowBits(&code_point, 6) */ ChopLowBits ( & code_point , 6 ) ) ; |
1951: str/* str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)) */ [ 2 ] = static_cast < char > 0x80 |&/* | ChopLowBits(&code_point, 6) */ ChopLowBits ( & code_point , 6 ) ) ; |
1952: str/* str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)) */ [ 1 ] = static_cast < char > 0x80 |&/* | ChopLowBits(&code_point, 6) */ ChopLowBits ( & code_point , 6 ) ) ; |
1953: str/* str[0] = static_cast<char>(0xF0 | code_point) */ [ 0 ] = static_cast < char > 0xF0 code_point ) ; |
| 1954: } |
| 1955: return str ; |
| 1956: } |
| 1957: |
| 1958: |
| 1959: |
| 1960: |
| 1961: |
| 1962: |
| 1963: |
| 1964: |
| 1965: inline bool IsUtf16SurrogatePair ( wchar_t first , wchar_t second ) { |
| 1966: return sizeoftruefalsetruefalsetruefalsetruefalsetruefalse ( wchar_t ) == 2 |
| 1967: first 0xFC00 ) == 0xD800 second 0xFC00 ) == 0xDC00 ; |
| 1968: } |
| 1969: |
| 1970: |
| 1971: inline uint32_t CreateCodePointFromUtf16SurrogatePair ( wchar_t first , |
| 1972: wchar_t second ) { |
| 1973: const auto first_u = static_cast < uint32_t > ( first ) ; |
| 1974: const auto second_u = static_cast < uint32_t > ( second ) ; |
| 1975: const uint32_t mask = ( 1 << 10 ) - 1 ; |
| 1976: return sizeof ( wchar_t ) == 2 ) |
| 1977: ? (/* ((first_u & mask) << 10) | */ ( first_u mask ) << 10 ) |&/* | (second_u & mask) */ second_u mask ) ) + 0x10000 |
| 1978: : |
| 1979: |
| 1980: |
| 1981: first_u ; |
| 1982: } |
| 1983: |
| 1984: |
| 1985: |
| 1986: |
| 1987: |
| 1988: |
| 1989: |
| 1990: |
| 1991: |
| 1992: |
| 1993: |
| 1994: |
| 1995: |
| 1996: |
| 1997: std :: string WideStringToUtf8 ( const wchar_t * str , int num_chars ) { |
1998: if/* if (num_chars == -1)
num_chars = static_cast<int>(wcslen(str)) */ num_chars == - 1 ) |
| 1999: num_chars = static_cast < int > ( wcslen ( str ) ) ; |
| 2000: |
| 2001: :: std :: stringstream stream ; |
2002: for/* for (int i = 0; i < num_chars; ++i) {
uint32_t unicode_code_point;
if (str[i] == L'\0') {
break;
} else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
str[i + 1]);
i++;
} else {
unicode_code_point = static_cast<uint32_t>(str[i]);
}
stream << CodePointToUtf8(unicode_code_point);
} */ ( int i = 0 ; i < num_chars ; ++ i ) {/*
uint32_t unicode_code_point;
if (str[i] == L'\0') {
break;
} else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
str[i + 1]);
i++;
} else {
unicode_code_point = static_cast<uint32_t>(str[i]);
}
stream << CodePointToUtf8(unicode_code_point);
*/ |
| 2003: uint32_t unicode_code_point ; |
| 2004: |
2005: if/* if (str[i] == L'\0') {
break;
} else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
str[i + 1]);
i++;
} else {
unicode_code_point = static_cast<uint32_t>(str[i]);
} */ str [ i ] == L'\0' ) { |
| 2006: break ; |
| 2007: } else if/* if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
str[i + 1]);
i++;
} else {
unicode_code_point = static_cast<uint32_t>(str[i]);
} */ (truefalsetruefalsetruefalse i + 1 < num_chars IsUtf16SurrogatePair ( str [ i ] , str [ i + 1 ] ) ) {/*
unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
str[i + 1]);
i++;
*/ |
2008: unicode_code_point/* unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
str[i + 1]) */ = CreateCodePointFromUtf16SurrogatePair ( str [ i ] , |
| 2009: str [ i + 1 ] ) ; |
| 2010: ++ ; |
| 2011: } else {/*
unicode_code_point = static_cast<uint32_t>(str[i]);
*/ |
2012: unicode_code_point/* unicode_code_point = static_cast<uint32_t>(str[i]) */ = static_cast < uint32_t > ( str [ i ] ) ; |
| 2013: } |
| 2014: |
| 2015: stream << CodePointToUtf8 ( unicode_code_point ) ; |
| 2016: } |
| 2017: return StringStreamToString ( & stream ) ; |
| 2018: } |
| 2019: |
| 2020: |
| 2021: |
| 2022: std :: string String :: ShowWideCString ( const wchar_t * wide_c_str ) { |
| 2023: if wide_c_str == nullptr ) return "(null)" ; |
| 2024: |
| 2025: return internal :: WideStringToUtf8 ( wide_c_str , - 1 ) ; |
| 2026: } |
| 2027: |
| 2028: |
| 2029: |
| 2030: |
| 2031: |
| 2032: |
| 2033: |
| 2034: bool String :: WideCStringEquals ( const wchar_t * lhs , const wchar_t * rhs ) { |
| 2035: if lhs == nullptr ) return == nullptr ; |
| 2036: |
| 2037: if rhs == nullptr ) return ; |
| 2038: |
| 2039: return ( lhs , rhs ) == 0 ; |
| 2040: } |
| 2041: |
| 2042: |
| 2043: AssertionResult CmpHelperSTREQ ( const char * lhs_expression , |
| 2044: const char * rhs_expression , |
| 2045: const wchar_t * lhs , |
| 2046: const wchar_t * rhs ) { |
| 2047: if String :: WideCStringEquals ( lhs , rhs ) ) { |
| 2048: return AssertionSuccess ( ) ; |
| 2049: } |
| 2050: |
| 2051: return EqFailure ( lhs_expression , |
| 2052: rhs_expression , |
| 2053: PrintToString ( lhs ) , |
| 2054: PrintToString ( rhs ) , |
| 2055: false ) ; |
| 2056: } |
| 2057: |
| 2058: |
| 2059: AssertionResult CmpHelperSTRNE ( const char * s1_expression , |
| 2060: const char * s2_expression , |
| 2061: const wchar_t * s1 , |
| 2062: const wchar_t * s2 ) { |
| 2063: if (truefalse!!String::WideCStringEquals(s1, s2) ! String :: WideCStringEquals ( s1 , s2 ) ) { |
| 2064: return AssertionSuccess ( ) ; |
| 2065: } |
| 2066: |
| 2067: return AssertionFailure ( ) << "Expected: (" << s1_expression << ") != (" |
| 2068: << s2_expression << "), actual: " |
| 2069: << PrintToString ( s1 ) |
| 2070: << " vs " << PrintToString ( s2 ) ; |
| 2071: } |
| 2072: |
| 2073: |
| 2074: |
| 2075: |
| 2076: |
| 2077: |
| 2078: |
| 2079: bool String :: CaseInsensitiveCStringEquals ( const char * lhs , const char * rhs ) { |
| 2080: if lhs == nullptr ) return == nullptr ; |
| 2081: if rhs == nullptr ) return ; |
| 2082: return :: StrCaseCmp ( lhs , rhs ) == 0 ; |
| 2083: } |
| 2084: |
| 2085: |
| 2086: |
| 2087: |
| 2088: |
| 2089: |
| 2090: |
| 2091: |
| 2092: |
| 2093: |
| 2094: |
| 2095: |
| 2096: |
| 2097: bool String :: CaseInsensitiveWideCStringEquals ( const wchar_t * lhs , |
| 2098: const wchar_t * rhs ) { |
| 2099: if lhs == nullptr ) return == nullptr ; |
| 2100: |
| 2101: if rhs == nullptr ) return ; |
| 2102: |
| 2103: # if GTEST_OS_WINDOWS |
| 2104: return _wcsicmp ( lhs , rhs ) == 0 ; |
| 2105: # elif GTEST_OS_LINUX && ! GTEST_OS_LINUX_ANDROID |
| 2106: return ( lhs , rhs ) == 0 ; |
| 2107: # else |
| 2108: |
| 2109: |
| 2110: wint_t left , right ; |
| 2111: do { |
| 2112: left = towlower ( static_cast < wint_t > ( * lhs ++ ) ) ; |
| 2113: right = towlower ( static_cast < wint_t > ( * rhs ++ ) ) ; |
| 2114: } while ( left && left == right ) ; |
| 2115: return left == right ; |
| 2116: # endif |
| 2117: } |
| 2118: |
| 2119: |
| 2120: |
| 2121: bool String :: EndsWithCaseInsensitive ( |
| 2122: const std :: string & str , const std :: string & suffix ) { |
| 2123: const size_t str_len = str . length ( ) ; |
| 2124: const size_t suffix_len = suffix . length ( ) ; |
| 2125: return (truefalsetruefalsetruefalse str_len >= suffix_len ) |
| 2126: CaseInsensitiveCStringEquals ( str . c_str ( ) + str_len - suffix_len , |
| 2127: suffix . c_str ( ) ) ; |
| 2128: } |
| 2129: |
| 2130: |
| 2131: std :: string String :: FormatIntWidth2 ( int value ) { |
| 2132: return FormatIntWidthN ( value , 2 ) ; |
| 2133: } |
| 2134: |
| 2135: |
| 2136: std :: string String :: FormatIntWidthN ( int value , int width ) { |
| 2137: std :: stringstream ss ; |
| 2138: ss << std :: setfill ( '0' ) << std :: setw ( width ) << value ; |
| 2139: return ss . str ( ) ; |
| 2140: } |
| 2141: |
| 2142: |
| 2143: std :: string String :: FormatHexUInt32 ( uint32_t value ) { |
| 2144: std :: stringstream ss ; |
2145: ss/* ss << std::hex << std::uppercase << value */ << std :: hex << std :: uppercase << value ; |
| 2146: return ss . str ( ) ; |
| 2147: } |
| 2148: |
| 2149: |
| 2150: std :: string String :: FormatHexInt ( int value ) { |
| 2151: return FormatHexUInt32 ( static_cast < uint32_t > ( value ) ) ; |
| 2152: } |
| 2153: |
| 2154: |
| 2155: std :: string String :: FormatByte ( unsigned char value ) { |
| 2156: std :: stringstream ss ; |
| 2157: ss << std :: setfill ( '0' ) << std :: setw ( 2 ) << std :: hex << std :: uppercase |
| 2158: << static_cast < unsigned int > ( value ) ; |
| 2159: return ss . str ( ) ; |
| 2160: } |
| 2161: |
| 2162: |
| 2163: |
| 2164: std :: string StringStreamToString ( :: std :: stringstream * ss ) { |
| 2165: const :: std :: string & str = ss -> str ( ) ; |
| 2166: const char * const start = str . c_str ( ) ; |
| 2167: const char * const end = start + str . length ( ) ; |
| 2168: |
| 2169: std :: string result ; |
2170: result/* result.reserve(static_cast<size_t>(2 * (end - start))) */ . reserve ( static_cast < size_t > ( 2 * ( end - start ) ) ) ; |
2171: for/* for (const char* ch = start; ch != end; ++ch) {
if (*ch == '\0') {
result += "\\0"; // Replaces NUL with "\\0";
} else {
result += *ch;
}
} */ ( const char * ch = start ; ch != end ; ++ ch ) {/*
if (*ch == '\0') {
result += "\\0"; // Replaces NUL with "\\0";
} else {
result += *ch;
}
*/ |
2172: if/* if (*ch == '\0') {
result += "\\0"; // Replaces NUL with "\\0";
} else {
result += *ch;
} */ * ch == '\0' ) {/*
result += "\\0"; // Replaces NUL with "\\0";
*/ |
2173: result/* result += "\\0" */ += "\\0" ; |
| 2174: } else |
2175: result/* result += *ch */ += * ch ; |
| 2176: } |
| 2177: } |
| 2178: |
| 2179: return result ; |
| 2180: } |
| 2181: |
| 2182: |
| 2183: std :: string AppendUserMessage ( const std :: string & gtest_msg , |
| 2184: const Message & user_msg ) { |
| 2185: |
| 2186: const std :: string user_msg_string = user_msg . GetString ( ) ; |
| 2187: if user_msg_string . empty ( ) ) { |
| 2188: return gtest_msg ; |
| 2189: } |
| 2190: if gtest_msg . empty ( ) ) { |
| 2191: return user_msg_string ; |
| 2192: } |
| 2193: return gtest_msg + "\n" + user_msg_string ; |
| 2194: } |
| 2195: |
| 2196: } |
| 2197: |
| 2198: |
| 2199: |
| 2200: |
| 2201: TestResult :: TestResult ( ) |
| 2202: : death_test_count_ ( 0 ) , start_timestamp_ ( 0 ) , elapsed_time_ ( 0 ) { } |
| 2203: |
| 2204: |
| 2205: TestResult :: ~ TestResult ( ) { |
| 2206: } |
| 2207: |
| 2208: |
| 2209: |
| 2210: |
| 2211: const TestPartResult & TestResult :: GetTestPartResult ( int i ) const { |
2212: if/* if (i < 0 || i >= total_part_count())
internal::posix::Abort() */ (truefalsetruefalsetruefalse i < 0 >= total_part_count ( ) ) |
| 2213: internal :: posix :: Abort ( ) ; |
| 2214: return test_part_results_ . at ( static_cast < size_t > ( i ) ) ; |
| 2215: } |
| 2216: |
| 2217: |
| 2218: |
| 2219: |
| 2220: const TestProperty & TestResult :: GetTestProperty ( int i ) const { |
2221: if/* if (i < 0 || i >= test_property_count())
internal::posix::Abort() */ (truefalsetruefalsetruefalse i < 0 >= test_property_count ( ) ) |
| 2222: internal :: posix :: Abort ( ) ; |
| 2223: return test_properties_ . at ( static_cast < size_t > ( i ) ) ; |
| 2224: } |
| 2225: |
| 2226: |
| 2227: void TestResult :: ClearTestPartResults ( ) {/*
test_part_results_.clear();
*/ |
2228: test_part_results_/* test_part_results_.clear() */ . clear ( ) ; |
| 2229: } |
| 2230: |
| 2231: |
| 2232: void TestResult :: AddTestPartResult ( const TestPartResult & test_part_result ) {/*
test_part_results_.push_back(test_part_result);
*/ |
2233: test_part_results_/* test_part_results_.push_back(test_part_result) */ . push_back ( test_part_result ) ; |
| 2234: } |
| 2235: |
| 2236: |
| 2237: |
| 2238: |
| 2239: void TestResult :: RecordProperty ( const std :: string & xml_element , |
| 2240: const TestProperty & test_property ) {/*
if (!ValidateTestProperty(xml_element, test_property)) {
return;
}
internal::MutexLock lock(&test_properties_mutex_);
const std::vector<TestProperty>::iterator property_with_matching_key =
std::find_if(test_properties_.begin(), test_properties_.end(),
internal::TestPropertyKeyIs(test_property.key()));
if (property_with_matching_key == test_properties_.end()) {
test_properties_.push_back(test_property);
return;
}
property_with_matching_key->SetValue(test_property.value());
*/ |
2241: if/* if (!ValidateTestProperty(xml_element, test_property)) {
return;
} */ (truefalse!!ValidateTestProperty(xml_element, test_property) ! ValidateTestProperty ( xml_element , test_property ) ) |
| 2242: ; |
| 2243: } |
| 2244: internal :: MutexLock lock ( & test_properties_mutex_ ) ; |
| 2245: const std :: vector < TestProperty > :: iterator property_with_matching_key = |
| 2246: std :: find_if ( test_properties_ . begin ( ) , test_properties_ . end ( ) , |
| 2247: internal :: TestPropertyKeyIs ( test_property . key ( ) ) ) ; |
2248: if/* if (property_with_matching_key == test_properties_.end()) {
test_properties_.push_back(test_property);
return;
} */ property_with_matching_key == test_properties_ . end ( ) ) {/*
test_properties_.push_back(test_property);
return;
*/ |
2249: test_properties_/* test_properties_.push_back(test_property) */ . push_back ( test_property ) ; |
| 2250: ; |
| 2251: } |
| 2252: property_with_matching_key -> SetValue ( test_property . value ( ) ) ; |
| 2253: } |
| 2254: |
| 2255: |
| 2256: |
| 2257: static const char * const kReservedTestSuitesAttributes [ ] = { |
| 2258: "disabled" , |
| 2259: "errors" , |
| 2260: "failures" , |
| 2261: "name" , |
| 2262: "random_seed" , |
| 2263: "tests" , |
| 2264: "time" , |
| 2265: "timestamp" |
| 2266: } ; |
| 2267: |
| 2268: |
| 2269: |
| 2270: static const char * const kReservedTestSuiteAttributes [ ] = { |
| 2271: "disabled" , "errors" , "failures" , "name" , |
| 2272: "tests" , "time" , "timestamp" , "skipped" } ; |
| 2273: |
| 2274: |
| 2275: static const char * const kReservedTestCaseAttributes [ ] = { |
| 2276: "classname" , "name" , "status" , "time" , "type_param" , |
| 2277: "value_param" , "file" , "line" } ; |
| 2278: |
| 2279: |
| 2280: |
| 2281: static const char * const kReservedOutputTestCaseAttributes [ ] = { |
| 2282: "classname" , "name" , "status" , "time" , "type_param" , |
| 2283: "value_param" , "file" , "line" , "result" , "timestamp" } ; |
| 2284: |
| 2285: template < size_t kSize > |
| 2286: std :: vector < std :: string > ArrayAsVector ( const char * const ( & array ) [ kSize ] ) { |
| 2287: return std :: vector < std :: string > ( array , array + kSize ) ; |
| 2288: } |
| 2289: |
| 2290: static std :: vector < std :: string > GetReservedAttributesForElement ( |
| 2291: const std :: string & xml_element ) { |
| 2292: if xml_element == "testsuites" ) { |
| 2293: return ArrayAsVector ( kReservedTestSuitesAttributes ) ; |
| 2294: } else if xml_element == "testsuite" ) { |
| 2295: return ArrayAsVector ( kReservedTestSuiteAttributes ) ; |
| 2296: } else if xml_element == "testcase" ) { |
| 2297: return ArrayAsVector ( kReservedTestCaseAttributes ) ; |
| 2298: } else {/*
GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
*/ |
| 2299: GTEST_CHECK_ ( false ) << "Unrecognized xml_element provided: " << xml_element ; |
| 2300: } |
| 2301: |
| 2302: return std :: vector < std :: string > ( ) ; |
| 2303: } |
| 2304: |
| 2305: |
| 2306: static std :: vector < std :: string > GetReservedOutputAttributesForElement ( |
| 2307: const std :: string & xml_element ) { |
| 2308: if xml_element == "testsuites" ) { |
| 2309: return ArrayAsVector ( kReservedTestSuitesAttributes ) ; |
| 2310: } else if xml_element == "testsuite" ) { |
| 2311: return ArrayAsVector ( kReservedTestSuiteAttributes ) ; |
| 2312: } else if xml_element == "testcase" ) { |
| 2313: return ArrayAsVector ( kReservedOutputTestCaseAttributes ) ; |
| 2314: } else {/*
GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
*/ |
| 2315: GTEST_CHECK_ ( false ) << "Unrecognized xml_element provided: " << xml_element ; |
| 2316: } |
| 2317: |
| 2318: return std :: vector < std :: string > ( ) ; |
| 2319: } |
| 2320: |
| 2321: static std :: string FormatWordList ( const std :: vector < std :: string > & words ) { |
| 2322: Message word_list ; |
2323: for/* for (size_t i = 0; i < words.size(); ++i) {
if (i > 0 && words.size() > 2) {
word_list << ", ";
}
if (i == words.size() - 1) {
word_list << "and ";
}
word_list << "'" << words[i] << "'";
} */ ( size_t i = 0 ; i < words . size ( ) ; ++ i ) {/*
if (i > 0 && words.size() > 2) {
word_list << ", ";
}
if (i == words.size() - 1) {
word_list << "and ";
}
word_list << "'" << words[i] << "'";
*/ |
2324: if/* if (i > 0 && words.size() > 2) {
word_list << ", ";
} */ (truefalsetruefalsetruefalse i > 0 . size ( ) > 2 ) {/*
word_list << ", ";
*/ |
2325: word_list/* word_list << ", " */ << ", " ; |
| 2326: } |
2327: if/* if (i == words.size() - 1) {
word_list << "and ";
} */ i == words . size ( ) - 1 ) {/*
word_list << "and ";
*/ |
2328: word_list/* word_list << "and " */ << "and " ; |
| 2329: } |
2330: word_list/* word_list << "'" << words[i] << "'" */ << "'" << words [ i ] << "'" ; |
| 2331: } |
| 2332: return word_list . GetString ( ) ; |
| 2333: } |
| 2334: |
| 2335: static bool ValidateTestPropertyName ( |
| 2336: const std :: string & property_name , |
| 2337: const std :: vector < std :: string > & reserved_names ) { |
| 2338: if std :: find ( reserved_names . begin ( ) , reserved_names . end ( ) , property_name ) != |
| 2339: reserved_names . end ( ) ) { |
| 2340: ADD_FAILURE ( ) << "Reserved key used in RecordProperty(): " << property_name |
| 2341: << " (" << FormatWordList ( reserved_names ) |
| 2342: << " are reserved by " << GTEST_NAME_ << ")" ; |
| 2343: return ; |
| 2344: } |
| 2345: return ; |
| 2346: } |
| 2347: |
| 2348: |
| 2349: |
| 2350: bool TestResult :: ValidateTestProperty ( const std :: string & xml_element , |
| 2351: const TestProperty & test_property ) { |
| 2352: return ValidateTestPropertyNametruefalse ( test_property . key ( ) , |
| 2353: GetReservedAttributesForElement ( xml_element ) ) ; |
| 2354: } |
| 2355: |
| 2356: |
| 2357: void TestResult :: Clear ( ) {/*
test_part_results_.clear();
test_properties_.clear();
death_test_count_ = 0;
elapsed_time_ = 0;
*/ |
2358: test_part_results_/* test_part_results_.clear() */ . clear ( ) ; |
2359: test_properties_/* test_properties_.clear() */ . clear ( ) ; |
2360: death_test_count_/* death_test_count_ = 0 */ = 0 ; |
2361: elapsed_time_/* elapsed_time_ = 0 */ = 0 ; |
| 2362: } |
| 2363: |
| 2364: |
| 2365: static bool TestPartSkipped ( const TestPartResult & result ) { |
| 2366: return . skipped ( ) ; |
| 2367: } |
| 2368: |
| 2369: |
| 2370: bool TestResult :: Skipped ( ) const { |
| 2371: return !!!Failed()truefalsetruefalse Failed ( ) ( test_part_results_ , TestPartSkipped ) > 0 ; |
| 2372: } |
| 2373: |
| 2374: |
| 2375: bool TestResult :: Failed ( ) const { |
| 2376: for ( int i = 0 ; i < total_part_count ( ) ; ++ i ) { |
| 2377: if GetTestPartResult ( i ) . failed ( ) ) |
| 2378: return ; |
| 2379: } |
| 2380: return ; |
| 2381: } |
| 2382: |
| 2383: |
| 2384: static bool TestPartFatallyFailed ( const TestPartResult & result ) { |
| 2385: return . fatally_failed ( ) ; |
| 2386: } |
| 2387: |
| 2388: |
| 2389: bool TestResult :: HasFatalFailure ( ) const { |
| 2390: return ( test_part_results_ , TestPartFatallyFailed ) > 0 ; |
| 2391: } |
| 2392: |
| 2393: |
| 2394: static bool TestPartNonfatallyFailed ( const TestPartResult & result ) { |
| 2395: return . nonfatally_failed ( ) ; |
| 2396: } |
| 2397: |
| 2398: |
| 2399: bool TestResult :: HasNonfatalFailure ( ) const { |
| 2400: return ( test_part_results_ , TestPartNonfatallyFailed ) > 0 ; |
| 2401: } |
| 2402: |
| 2403: |
| 2404: |
| 2405: int TestResult :: total_part_count ( ) const { |
| 2406: return static_cast < int > ( test_part_results_ . size ( ) ) ; |
| 2407: } |
| 2408: |
| 2409: |
| 2410: int TestResult :: test_property_count ( ) const { |
| 2411: return static_cast < int > ( test_properties_ . size ( ) ) ; |
| 2412: } |
| 2413: |
| 2414: |
| 2415: |
| 2416: |
| 2417: |
| 2418: |
| 2419: Test :: Test ( ) |
| 2420: : gtest_flag_saver_ ( new GTEST_FLAG_SAVER_ ) { |
| 2421: } |
| 2422: |
| 2423: |
| 2424: |
| 2425: |
| 2426: Test :: ~ Test ( ) { |
| 2427: } |
| 2428: |
| 2429: |
| 2430: |
| 2431: |
| 2432: void Test :: SetUp ( ) { |
| 2433: } |
| 2434: |
| 2435: |
| 2436: |
| 2437: |
| 2438: void Test :: TearDown ( ) { |
| 2439: } |
| 2440: |
| 2441: |
| 2442: void Test :: RecordProperty ( const std :: string & key , const std :: string & value ) {/*
UnitTest::GetInstance()->RecordProperty(key, value);
*/ |
2443: UnitTest/* UnitTest::GetInstance()->RecordProperty(key, value) */ :: GetInstance ( ) -> RecordProperty ( key , value ) ; |
| 2444: } |
| 2445: |
| 2446: |
| 2447: void Test :: RecordProperty ( const std :: string & key , int value ) {/*
Message value_message;
value_message << value;
RecordProperty(key, value_message.GetString().c_str());
*/ |
| 2448: Message value_message ; |
2449: value_message/* value_message << value */ << value ; |
| 2450: RecordProperty ( key , value_message . GetString ( ) . c_str ( ) ) ; |
| 2451: } |
| 2452: |
| 2453: namespace internal { |
| 2454: |
| 2455: void ReportFailureInUnknownLocation ( TestPartResult :: Type result_type , |
| 2456: const std :: string & message ) {/*
// This function is a friend of UnitTest and as such has access to
// AddTestPartResult.
UnitTest::GetInstance()->AddTestPartResult(
result_type,
nullptr, // No info about the source file where the exception occurred.
-1, // We have no info on which line caused the exception.
message,
""); // No stack trace, either.
*/ |
| 2457: |
| 2458: |
| 2459: UnitTest :: GetInstance ( ) -> AddTestPartResult ( |
| 2460: result_type , |
| 2461: nullptr , |
| 2462: - 1 , |
| 2463: message , |
| 2464: "" ) ; |
| 2465: } |
| 2466: |
| 2467: } |
| 2468: |
| 2469: |
| 2470: |
| 2471: |
| 2472: |
| 2473: |
| 2474: bool Test :: HasSameFixtureClass ( ) { |
| 2475: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
| 2476: const TestSuite * const test_suite = impl -> current_test_suite ( ) ; |
| 2477: |
| 2478: |
| 2479: const TestInfo * const first_test_info = test_suite -> test_info_list ( ) [ 0 ] ; |
| 2480: const internal :: TypeId first_fixture_id = first_test_info -> fixture_class_id_ ; |
| 2481: const char * const first_test_name = first_test_info -> name ( ) ; |
| 2482: |
| 2483: |
| 2484: const TestInfo * const this_test_info = impl -> current_test_info ( ) ; |
| 2485: const internal :: TypeId this_fixture_id = this_test_info -> fixture_class_id_ ; |
| 2486: const char * const this_test_name = this_test_info -> name ( ) ; |
| 2487: |
| 2488: if this_fixture_id != first_fixture_id ) { |
| 2489: |
| 2490: const bool first_is_TEST = first_fixture_idtruefalse == internal :: GetTestTypeId ( ) ; |
| 2491: |
| 2492: const bool this_is_TEST = == internal :: GetTestTypeId ( ) ; |
| 2493: |
2494: if/* if (first_is_TEST || this_is_TEST) {
// Both TEST and TEST_F appear in same test suite, which is incorrect.
// Tell the user how to fix this.
// Gets the name of the TEST and the name of the TEST_F. Note
// that first_is_TEST and this_is_TEST cannot both be true, as
// the fixture IDs are different for the two tests.
const char* const TEST_name =
first_is_TEST ? first_test_name : this_test_name;
const char* const TEST_F_name =
first_is_TEST ? this_test_name : first_test_name;
ADD_FAILURE()
<< "All tests in the same test suite must use the same test fixture\n"
<< "class, so mixing TEST_F and TEST in the same test suite is\n"
<< "illegal. In test suite " << this_test_info->test_suite_name()
<< ",\n"
<< "test " << TEST_F_name << " is defined using TEST_F but\n"
<< "test " << TEST_name << " is defined using TEST. You probably\n"
<< "want to change the TEST to TEST_F or move it to another test\n"
<< "case.";
} else {
// Two fixture classes with the same name appear in two different
// namespaces, which is not allowed. Tell the user how to fix this.
ADD_FAILURE()
<< "All tests in the same test suite must use the same test fixture\n"
<< "class. However, in test suite "
<< this_test_info->test_suite_name() << ",\n"
<< "you defined test " << first_test_name << " and test "
<< this_test_name << "\n"
<< "using two different test fixture classes. This can happen if\n"
<< "the two classes are from different namespaces or translation\n"
<< "units and have the same name. You should probably rename one\n"
<< "of the classes to put the tests into different test suites.";
} */ first_is_TEST this_is_TEST ) {/*
// Both TEST and TEST_F appear in same test suite, which is incorrect.
// Tell the user how to fix this.
// Gets the name of the TEST and the name of the TEST_F. Note
// that first_is_TEST and this_is_TEST cannot both be true, as
// the fixture IDs are different for the two tests.
const char* const TEST_name =
first_is_TEST ? first_test_name : this_test_name;
const char* const TEST_F_name =
first_is_TEST ? this_test_name : first_test_name;
ADD_FAILURE()
<< "All tests in the same test suite must use the same test fixture\n"
<< "class, so mixing TEST_F and TEST in the same test suite is\n"
<< "illegal. In test suite " << this_test_info->test_suite_name()
<< ",\n"
<< "test " << TEST_F_name << " is defined using TEST_F but\n"
<< "test " << TEST_name << " is defined using TEST. You probably\n"
<< "want to change the TEST to TEST_F or move it to another test\n"
<< "case.";
*/ |
| 2495: |
| 2496: |
| 2497: |
| 2498: |
| 2499: |
| 2500: |
| 2501: const char * const TEST_name = |
| 2502: first_is_TEST ? first_test_name : this_test_name ; |
| 2503: const char * const TEST_F_name = |
| 2504: first_is_TEST ? this_test_name : first_test_name ; |
| 2505: |
| 2506: ADD_FAILURE ( ) |
| 2507: << "All tests in the same test suite must use the same test fixture\n" |
| 2508: << "class, so mixing TEST_F and TEST in the same test suite is\n" |
| 2509: << "illegal. In test suite " << this_test_info -> test_suite_name ( ) |
| 2510: << ",\n" |
| 2511: << "test " << TEST_F_name << " is defined using TEST_F but\n" |
| 2512: << "test " << TEST_name << " is defined using TEST. You probably\n" |
| 2513: << "want to change the TEST to TEST_F or move it to another test\n" |
| 2514: << "case." ; |
| 2515: } else {/*
// Two fixture classes with the same name appear in two different
// namespaces, which is not allowed. Tell the user how to fix this.
ADD_FAILURE()
<< "All tests in the same test suite must use the same test fixture\n"
<< "class. However, in test suite "
<< this_test_info->test_suite_name() << ",\n"
<< "you defined test " << first_test_name << " and test "
<< this_test_name << "\n"
<< "using two different test fixture classes. This can happen if\n"
<< "the two classes are from different namespaces or translation\n"
<< "units and have the same name. You should probably rename one\n"
<< "of the classes to put the tests into different test suites.";
*/ |
| 2516: |
| 2517: |
| 2518: ADD_FAILURE ( ) |
| 2519: << "All tests in the same test suite must use the same test fixture\n" |
| 2520: << "class. However, in test suite " |
| 2521: << this_test_info -> test_suite_name ( ) << ",\n" |
| 2522: << "you defined test " << first_test_name << " and test " |
| 2523: << this_test_name << "\n" |
| 2524: << "using two different test fixture classes. This can happen if\n" |
| 2525: << "the two classes are from different namespaces or translation\n" |
| 2526: << "units and have the same name. You should probably rename one\n" |
| 2527: << "of the classes to put the tests into different test suites." ; |
| 2528: } |
| 2529: return ; |
| 2530: } |
| 2531: |
| 2532: return ; |
| 2533: } |
| 2534: |
| 2535: # if GTEST_HAS_SEH |
| 2536: |
| 2537: |
| 2538: |
| 2539: |
| 2540: |
| 2541: static std :: string * FormatSehExceptionMessage ( DWORD exception_code , |
| 2542: const char * location ) { |
| 2543: Message message ; |
| 2544: message << "SEH exception with code 0x" << std :: setbase ( 16 ) << |
| 2545: exception_code << std :: setbase ( 10 ) << " thrown in " << location << "." ; |
| 2546: |
| 2547: return new std :: string ( message . GetString ( ) ) ; |
| 2548: } |
| 2549: |
| 2550: # endif |
| 2551: |
| 2552: namespace internal { |
| 2553: |
| 2554: # if GTEST_HAS_EXCEPTIONS |
| 2555: |
| 2556: |
| 2557: static std :: string FormatCxxExceptionMessage ( const char * description , |
| 2558: const char * location ) { |
| 2559: Message message ; |
2560: if/* if (description != nullptr) {
message << "C++ exception with description \"" << description << "\"";
} else {
message << "Unknown C++ exception";
} */ description != nullptr ) {/*
message << "C++ exception with description \"" << description << "\"";
*/ |
2561: message/* message << "C++ exception with description \"" << description << "\"" */ << "C++ exception with description \"" << description << "\"" ; |
| 2562: } else {/*
message << "Unknown C++ exception";
*/ |
2563: message/* message << "Unknown C++ exception" */ << "Unknown C++ exception" ; |
| 2564: } |
2565: message/* message << " thrown in " << location << "." */ << " thrown in " << location << "." ; |
| 2566: |
| 2567: return message . GetString ( ) ; |
| 2568: } |
| 2569: |
| 2570: static std :: string PrintTestPartResultToString ( |
| 2571: const TestPartResult & test_part_result ) ; |
| 2572: |
| 2573: GoogleTestFailureException :: GoogleTestFailureException ( |
| 2574: const TestPartResult & failure ) |
| 2575: : :: std :: runtime_error ( PrintTestPartResultToString ( failure ) . c_str ( ) ) { } |
| 2576: |
| 2577: # endif |
| 2578: |
| 2579: |
| 2580: |
| 2581: |
| 2582: |
| 2583: |
| 2584: |
| 2585: |
| 2586: |
| 2587: template < class T , typename Result > |
| 2588: Result HandleSehExceptionsInMethodIfSupported ( |
| 2589: T * object , Result ( T :: * method ) ( ) , const char * location ) { |
| 2590: # if GTEST_HAS_SEH |
| 2591: __try { |
| 2592: return ( object ->* method ) ( ) ; |
| 2593: } __except ( internal :: UnitTestOptions :: GTestShouldProcessSEH ( |
| 2594: GetExceptionCode ( ) ) ) { |
| 2595: |
| 2596: |
| 2597: |
| 2598: std :: string * exception_message = FormatSehExceptionMessage ( |
| 2599: GetExceptionCode ( ) , location ) ; |
| 2600: internal :: ReportFailureInUnknownLocation ( TestPartResult :: kFatalFailure , |
| 2601: * exception_message ) ; |
| 2602: delete exception_message ; |
| 2603: return static_cast < Result > ( 0 ) ; |
| 2604: } |
| 2605: # else |
| 2606: ( void ) location ; |
| 2607: return ( object ->* method ) ( ) ; |
| 2608: # endif |
| 2609: } |
| 2610: |
| 2611: |
| 2612: |
| 2613: |
| 2614: template < class T , typename Result > |
| 2615: Result HandleExceptionsInMethodIfSupported ( |
| 2616: T * object , Result ( T :: * method ) ( ) , const char * location ) { |
| 2617: |
| 2618: |
| 2619: |
| 2620: |
| 2621: |
| 2622: |
| 2623: |
| 2624: |
| 2625: |
| 2626: |
| 2627: |
| 2628: |
| 2629: |
| 2630: |
| 2631: |
| 2632: |
| 2633: |
| 2634: |
| 2635: |
| 2636: |
| 2637: |
| 2638: |
| 2639: |
| 2640: if internal :: GetUnitTestImpl ( ) -> catch_exceptions ( ) ) { |
| 2641: # if GTEST_HAS_EXCEPTIONS |
| 2642: try { |
| 2643: return HandleSehExceptionsInMethodIfSupported ( object , method , location ) ; |
| 2644: } catch ( const AssertionException & ) { |
| 2645: |
| 2646: } catch ( const internal :: GoogleTestFailureException & ) {/* // NOLINT
// This exception type can only be thrown by a failed Google
// Test assertion with the intention of letting another testing
// framework catch it. Therefore we just re-throw it.
throw;
*/ |
| 2647: |
| 2648: |
| 2649: |
| 2650: throw ; |
| 2651: } catch ( const std :: exception & e ) {/* // NOLINT
internal::ReportFailureInUnknownLocation(
TestPartResult::kFatalFailure,
FormatCxxExceptionMessage(e.what(), location));
*/ |
| 2652: internal :: ReportFailureInUnknownLocation ( |
| 2653: TestPartResult :: kFatalFailure , |
| 2654: FormatCxxExceptionMessage ( e . what ( ) , location ) ) ; |
| 2655: } catch ( ... ) {/* // NOLINT
internal::ReportFailureInUnknownLocation(
TestPartResult::kFatalFailure,
FormatCxxExceptionMessage(nullptr, location));
*/ |
| 2656: internal :: ReportFailureInUnknownLocation ( |
| 2657: TestPartResult :: kFatalFailure , |
| 2658: FormatCxxExceptionMessage ( nullptr , location ) ) ; |
| 2659: } |
| 2660: return static_cast < Result > ( 0 ) ; |
| 2661: # else |
| 2662: return HandleSehExceptionsInMethodIfSupported ( object , method , location ) ; |
| 2663: # endif |
| 2664: } else { |
| 2665: return ( object ->* method ) ( ) ; |
| 2666: } |
| 2667: } |
| 2668: |
| 2669: } |
| 2670: |
| 2671: |
| 2672: void Test :: Run ( ) {/*
if (!HasSameFixtureClass()) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
// We will run the test only if SetUp() was successful and didn't call
// GTEST_SKIP().
if (!HasFatalFailure() && !IsSkipped()) {
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &Test::TestBody, "the test body");
}
// However, we want to clean up as much as possible. Hence we will
// always call TearDown(), even if SetUp() or the test body has
// failed.
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &Test::TearDown, "TearDown()");
*/ |
2673: if/* if (!HasSameFixtureClass()) return */ (truefalse!!HasSameFixtureClass() ! HasSameFixtureClass ( ) ) ; |
| 2674: |
| 2675: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
2676: impl/* impl->os_stack_trace_getter()->UponLeavingGTest() */ -> os_stack_trace_getter ( ) -> UponLeavingGTest ( ) ; |
2677: internal/* internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()") */ :: HandleExceptionsInMethodIfSupported ( this , & Test :: SetUp , "SetUp()" ) ; |
| 2678: |
| 2679: |
2680: if/* if (!HasFatalFailure() && !IsSkipped()) {
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &Test::TestBody, "the test body");
} */ (!!HasFatalFailure()truefalsetruefalse ! HasFatalFailure ( ) IsSkipped ( ) ) {/*
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &Test::TestBody, "the test body");
*/ |
2681: impl/* impl->os_stack_trace_getter()->UponLeavingGTest() */ -> os_stack_trace_getter ( ) -> UponLeavingGTest ( ) ; |
2682: internal/* internal::HandleExceptionsInMethodIfSupported(
this, &Test::TestBody, "the test body") */ :: HandleExceptionsInMethodIfSupported ( |
| 2683: this , & Test :: TestBody , "the test body" ) ; |
| 2684: } |
| 2685: |
| 2686: |
| 2687: |
| 2688: |
2689: impl/* impl->os_stack_trace_getter()->UponLeavingGTest() */ -> os_stack_trace_getter ( ) -> UponLeavingGTest ( ) ; |
2690: internal/* internal::HandleExceptionsInMethodIfSupported(
this, &Test::TearDown, "TearDown()") */ :: HandleExceptionsInMethodIfSupported ( |
| 2691: this , & Test :: TearDown , "TearDown()" ) ; |
| 2692: } |
| 2693: |
| 2694: |
| 2695: bool Test :: HasFatalFailure ( ) { |
| 2696: return :: GetUnitTestImpl ( ) -> current_test_result ( ) -> HasFatalFailure ( ) ; |
| 2697: } |
| 2698: |
| 2699: |
| 2700: bool Test :: HasNonfatalFailure ( ) { |
| 2701: return :: GetUnitTestImpl ( ) -> current_test_result ( ) -> |
| 2702: HasNonfatalFailure ( ) ; |
| 2703: } |
| 2704: |
| 2705: |
| 2706: bool Test :: IsSkipped ( ) { |
| 2707: return :: GetUnitTestImpl ( ) -> current_test_result ( ) -> Skipped ( ) ; |
| 2708: } |
| 2709: |
| 2710: |
| 2711: |
| 2712: |
| 2713: |
| 2714: TestInfo :: TestInfo ( const std :: string & a_test_suite_name , |
| 2715: const std :: string & a_name , const char * a_type_param , |
| 2716: const char * a_value_param , |
| 2717: internal :: CodeLocation a_code_location , |
| 2718: internal :: TypeId fixture_class_id , |
| 2719: internal :: TestFactoryBase * factory ) |
| 2720: : test_suite_name_ ( a_test_suite_name ) , |
| 2721: name_ ( a_name ) , |
| 2722: type_param_ ( a_type_param ? new std :: string ( a_type_param ) : nullptr ) , |
| 2723: value_param_ ( a_value_param ? new std :: string ( a_value_param ) : nullptr ) , |
| 2724: location_ ( a_code_location ) , |
| 2725: fixture_class_id_ ( fixture_class_id ) , |
| 2726: should_run_ ( false ) , |
| 2727: is_disabled_ ( false ) , |
| 2728: matches_filter_ ( false ) , |
| 2729: is_in_another_shard_ ( false ) , |
| 2730: factory_ ( factory ) , |
| 2731: result_ ( ) { } |
| 2732: |
| 2733: |
| 2734: TestInfo :: ~ TestInfo ( ) delete factory_ ; } |
| 2735: |
| 2736: namespace internal { |
| 2737: |
| 2738: |
| 2739: |
| 2740: |
| 2741: |
| 2742: |
| 2743: |
| 2744: |
| 2745: |
| 2746: |
| 2747: |
| 2748: |
| 2749: |
| 2750: |
| 2751: |
| 2752: |
| 2753: |
| 2754: |
| 2755: |
| 2756: TestInfo * MakeAndRegisterTestInfo ( |
| 2757: const char * test_suite_name , const char * name , const char * type_param , |
| 2758: const char * value_param , CodeLocation code_location , |
| 2759: TypeId fixture_class_id , SetUpTestSuiteFunc set_up_tc , |
| 2760: TearDownTestSuiteFunc tear_down_tc , TestFactoryBase * factory ) { |
| 2761: TestInfo * const test_info = |
| 2762: new TestInfo ( test_suite_name , name , type_param , value_param , |
| 2763: code_location , fixture_class_id , factory ) ; |
2764: GetUnitTestImpl/* GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info) */ ( ) -> AddTestInfo ( set_up_tc , tear_down_tc , test_info ) ; |
| 2765: return test_info ; |
| 2766: } |
| 2767: |
| 2768: void ReportInvalidTestSuiteType ( const char * test_suite_name , |
| 2769: CodeLocation code_location ) {/*
Message errors;
errors
<< "Attempted redefinition of test suite " << test_suite_name << ".\n"
<< "All tests in the same test suite must use the same test fixture\n"
<< "class. However, in test suite " << test_suite_name << ", you tried\n"
<< "to define a test using a fixture class different from the one\n"
<< "used earlier. This can happen if the two fixture classes are\n"
<< "from different namespaces and have the same name. You should\n"
<< "probably rename one of the classes to put the tests into different\n"
<< "test suites.";
GTEST_LOG_(ERROR) << FormatFileLocation(code_location.file.c_str(),
code_location.line)
<< " " << errors.GetString();
*/ |
| 2770: Message errors ; |
2771: errors/* errors
<< "Attempted redefinition of test suite " << test_suite_name << ".\n"
<< "All tests in the same test suite must use the same test fixture\n"
<< "class. However, in test suite " << test_suite_name << ", you tried\n"
<< "to define a test using a fixture class different from the one\n"
<< "used earlier. This can happen if the two fixture classes are\n"
<< "from different namespaces and have the same name. You should\n"
<< "probably rename one of the classes to put the tests into different\n"
<< "test suites." */ |
| 2772: << "Attempted redefinition of test suite " << test_suite_name << ".\n" |
| 2773: << "All tests in the same test suite must use the same test fixture\n" |
| 2774: << "class. However, in test suite " << test_suite_name << ", you tried\n" |
| 2775: << "to define a test using a fixture class different from the one\n" |
| 2776: << "used earlier. This can happen if the two fixture classes are\n" |
| 2777: << "from different namespaces and have the same name. You should\n" |
| 2778: << "probably rename one of the classes to put the tests into different\n" |
| 2779: << "test suites." ; |
| 2780: |
| 2781: GTEST_LOG_ ( ERROR ) << FormatFileLocation ( code_location . file . c_str ( ) , |
| 2782: code_location . line ) |
| 2783: << " " << errors . GetString ( ) ; |
| 2784: } |
| 2785: } |
| 2786: |
| 2787: namespace { |
| 2788: |
| 2789: |
| 2790: |
| 2791: |
| 2792: |
| 2793: |
| 2794: |
| 2795: |
| 2796: |
| 2797: class TestNameIs { |
| 2798: public : |
| 2799: |
| 2800: |
| 2801: |
| 2802: explicit TestNameIs ( const char * name ) |
| 2803: : name_ ( name ) { } |
| 2804: |
| 2805: |
| 2806: bool operator ( ) ( const TestInfo * test_info ) const { |
| 2807: return test_infotruefalsetruefalse -> name ( ) == name_ ; |
| 2808: } |
| 2809: |
| 2810: private : |
| 2811: std :: string name_ ; |
| 2812: } ; |
| 2813: |
| 2814: } |
| 2815: |
| 2816: namespace internal { |
| 2817: |
| 2818: |
| 2819: |
| 2820: |
| 2821: void UnitTestImpl :: RegisterParameterizedTests ( ) {/*
if (!parameterized_tests_registered_) {
parameterized_test_registry_.RegisterTests();
type_parameterized_test_registry_.CheckForInstantiations();
parameterized_tests_registered_ = true;
}
*/ |
2822: if/* if (!parameterized_tests_registered_) {
parameterized_test_registry_.RegisterTests();
type_parameterized_test_registry_.CheckForInstantiations();
parameterized_tests_registered_ = true;
} */ (truefalse!!parameterized_tests_registered_ ! parameterized_tests_registered_ ) {/*
parameterized_test_registry_.RegisterTests();
type_parameterized_test_registry_.CheckForInstantiations();
parameterized_tests_registered_ = true;
*/ |
2823: parameterized_test_registry_/* parameterized_test_registry_.RegisterTests() */ . RegisterTests ( ) ; |
2824: type_parameterized_test_registry_/* type_parameterized_test_registry_.CheckForInstantiations() */ . CheckForInstantiations ( ) ; |
2825: parameterized_tests_registered_/* parameterized_tests_registered_ = true */ = true ; |
| 2826: } |
| 2827: } |
| 2828: |
| 2829: } |
| 2830: |
| 2831: |
| 2832: |
| 2833: void TestInfo :: Run ( ) {/*
if (!should_run_) return;
// Tells UnitTest where to store test result.
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->set_current_test_info(this);
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
// Notifies the unit test event listeners that a test is about to start.
repeater->OnTestStart(*this);
result_.set_start_timestamp(internal::GetTimeInMillis());
internal::Timer timer;
impl->os_stack_trace_getter()->UponLeavingGTest();
// Creates the test object.
Test* const test = internal::HandleExceptionsInMethodIfSupported(
factory_, &internal::TestFactoryBase::CreateTest,
"the test fixture's constructor");
// Runs the test if the constructor didn't generate a fatal failure or invoke
// GTEST_SKIP().
// Note that the object will not be null
if (!Test::HasFatalFailure() && !Test::IsSkipped()) {
// This doesn't throw as all user code that can throw are wrapped into
// exception handling code.
test->Run();
}
if (test != nullptr) {
// Deletes the test object.
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
test, &Test::DeleteSelf_, "the test fixture's destructor");
}
result_.set_elapsed_time(timer.Elapsed());
// Notifies the unit test event listener that a test has just finished.
repeater->OnTestEnd(*this);
// Tells UnitTest to stop associating assertion results to this
// test.
impl->set_current_test_info(nullptr);
*/ |
2834: if/* if (!should_run_) return */ ! should_run_ ) ; |
| 2835: |
| 2836: |
| 2837: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
2838: impl/* impl->set_current_test_info(this) */ -> set_current_test_info ( this ) ; |
| 2839: |
| 2840: TestEventListener * repeater = UnitTest :: GetInstance ( ) -> listeners ( ) . repeater ( ) ; |
| 2841: |
| 2842: |
2843: repeater/* repeater->OnTestStart(*this) */ -> OnTestStart ( * this ) ; |
| 2844: |
2845: result_/* result_.set_start_timestamp(internal::GetTimeInMillis()) */ . set_start_timestamp ( internal :: GetTimeInMillis ( ) ) ; |
| 2846: internal :: Timer timer ; |
| 2847: |
2848: impl/* impl->os_stack_trace_getter()->UponLeavingGTest() */ -> os_stack_trace_getter ( ) -> UponLeavingGTest ( ) ; |
| 2849: |
| 2850: |
| 2851: Test * const test = internal :: HandleExceptionsInMethodIfSupported ( |
| 2852: factory_ , & internal :: TestFactoryBase :: CreateTest , |
| 2853: "the test fixture's constructor" ) ; |
| 2854: |
| 2855: |
| 2856: |
| 2857: |
2858: if/* if (!Test::HasFatalFailure() && !Test::IsSkipped()) {
// This doesn't throw as all user code that can throw are wrapped into
// exception handling code.
test->Run();
} */ (!!Test::HasFatalFailure()truefalsetruefalse ! Test :: HasFatalFailure ( ) Test :: IsSkipped ( ) ) {/*
// This doesn't throw as all user code that can throw are wrapped into
// exception handling code.
test->Run();
*/ |
| 2859: |
| 2860: |
| 2861: -> Run ( ) ; |
| 2862: } |
| 2863: |
2864: if/* if (test != nullptr) {
// Deletes the test object.
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
test, &Test::DeleteSelf_, "the test fixture's destructor");
} */ test != nullptr ) {/*
// Deletes the test object.
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
test, &Test::DeleteSelf_, "the test fixture's destructor");
*/ |
| 2865: |
2866: impl/* impl->os_stack_trace_getter()->UponLeavingGTest() */ -> os_stack_trace_getter ( ) -> UponLeavingGTest ( ) ; |
2867: internal/* internal::HandleExceptionsInMethodIfSupported(
test, &Test::DeleteSelf_, "the test fixture's destructor") */ :: HandleExceptionsInMethodIfSupported ( |
| 2868: test , & Test :: DeleteSelf_ , "the test fixture's destructor" ) ; |
| 2869: } |
| 2870: |
2871: result_/* result_.set_elapsed_time(timer.Elapsed()) */ . set_elapsed_time ( timer . Elapsed ( ) ) ; |
| 2872: |
| 2873: |
2874: repeater/* repeater->OnTestEnd(*this) */ -> OnTestEnd ( * this ) ; |
| 2875: |
| 2876: |
| 2877: |
2878: impl/* impl->set_current_test_info(nullptr) */ -> set_current_test_info ( nullptr ) ; |
| 2879: } |
| 2880: |
| 2881: |
| 2882: void TestInfo :: Skip ( ) {/*
if (!should_run_) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->set_current_test_info(this);
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
// Notifies the unit test event listeners that a test is about to start.
repeater->OnTestStart(*this);
const TestPartResult test_part_result =
TestPartResult(TestPartResult::kSkip, this->file(), this->line(), "");
impl->GetTestPartResultReporterForCurrentThread()->ReportTestPartResult(
test_part_result);
// Notifies the unit test event listener that a test has just finished.
repeater->OnTestEnd(*this);
impl->set_current_test_info(nullptr);
*/ |
2883: if/* if (!should_run_) return */ ! should_run_ ) ; |
| 2884: |
| 2885: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
2886: impl/* impl->set_current_test_info(this) */ -> set_current_test_info ( this ) ; |
| 2887: |
| 2888: TestEventListener * repeater = UnitTest :: GetInstance ( ) -> listeners ( ) . repeater ( ) ; |
| 2889: |
| 2890: |
2891: repeater/* repeater->OnTestStart(*this) */ -> OnTestStart ( * this ) ; |
| 2892: |
| 2893: const TestPartResult test_part_result = |
| 2894: TestPartResult ( TestPartResult :: kSkip , this -> file ( ) , this -> line ( ) , "" ) ; |
2895: impl/* impl->GetTestPartResultReporterForCurrentThread()->ReportTestPartResult(
test_part_result) */ -> GetTestPartResultReporterForCurrentThread ( ) -> ReportTestPartResult ( |
| 2896: test_part_result ) ; |
| 2897: |
| 2898: |
2899: repeater/* repeater->OnTestEnd(*this) */ -> OnTestEnd ( * this ) ; |
2900: impl/* impl->set_current_test_info(nullptr) */ -> set_current_test_info ( nullptr ) ; |
| 2901: } |
| 2902: |
| 2903: |
| 2904: |
| 2905: |
| 2906: int TestSuite :: successful_test_count ( ) const { |
| 2907: return CountIf ( test_info_list_ , TestPassed ) ; |
| 2908: } |
| 2909: |
| 2910: |
| 2911: int TestSuite :: skipped_test_count ( ) const { |
| 2912: return CountIf ( test_info_list_ , TestSkipped ) ; |
| 2913: } |
| 2914: |
| 2915: |
| 2916: int TestSuite :: failed_test_count ( ) const { |
| 2917: return CountIf ( test_info_list_ , TestFailed ) ; |
| 2918: } |
| 2919: |
| 2920: |
| 2921: int TestSuite :: reportable_disabled_test_count ( ) const { |
| 2922: return CountIf ( test_info_list_ , TestReportableDisabled ) ; |
| 2923: } |
| 2924: |
| 2925: |
| 2926: int TestSuite :: disabled_test_count ( ) const { |
| 2927: return CountIf ( test_info_list_ , TestDisabled ) ; |
| 2928: } |
| 2929: |
| 2930: |
| 2931: int TestSuite :: reportable_test_count ( ) const { |
| 2932: return CountIf ( test_info_list_ , TestReportable ) ; |
| 2933: } |
| 2934: |
| 2935: |
| 2936: int TestSuite :: test_to_run_count ( ) const { |
| 2937: return CountIf ( test_info_list_ , ShouldRunTest ) ; |
| 2938: } |
| 2939: |
| 2940: |
| 2941: int TestSuite :: total_test_count ( ) const { |
| 2942: return static_cast < int > ( test_info_list_ . size ( ) ) ; |
| 2943: } |
| 2944: |
| 2945: |
| 2946: |
| 2947: |
| 2948: |
| 2949: |
| 2950: |
| 2951: |
| 2952: |
| 2953: |
| 2954: TestSuite :: TestSuite ( const char * a_name , const char * a_type_param , |
| 2955: internal :: SetUpTestSuiteFunc set_up_tc , |
| 2956: internal :: TearDownTestSuiteFunc tear_down_tc ) |
| 2957: : name_ ( a_name ) , |
| 2958: type_param_ ( a_type_param ? new std :: string ( a_type_param ) : nullptr ) , |
| 2959: set_up_tc_ ( set_up_tc ) , |
| 2960: tear_down_tc_ ( tear_down_tc ) , |
| 2961: should_run_ ( false ) , |
| 2962: start_timestamp_ ( 0 ) , |
| 2963: elapsed_time_ ( 0 ) { } |
| 2964: |
| 2965: |
| 2966: TestSuite :: ~ TestSuite ( ) {/*
// Deletes every Test in the collection.
ForEach(test_info_list_, internal::Delete<TestInfo>);
*/ |
| 2967: |
| 2968: ForEach ( test_info_list_ , internal :: Delete < TestInfo > ) ; |
| 2969: } |
| 2970: |
| 2971: |
| 2972: |
| 2973: const TestInfo * TestSuite :: GetTestInfo ( int i ) const { |
| 2974: const int index = GetElementOr ( test_indices_ , i , - 1 ) ; |
| 2975: return < 0 ? nullptr : test_info_list_ [ static_cast < size_t > ( index ) ] ; |
| 2976: } |
| 2977: |
| 2978: |
| 2979: |
| 2980: TestInfo * TestSuite :: GetMutableTestInfo ( int i ) { |
| 2981: const int index = GetElementOr ( test_indices_ , i , - 1 ) ; |
| 2982: return < 0 ? nullptr : test_info_list_ [ static_cast < size_t > ( index ) ] ; |
| 2983: } |
| 2984: |
| 2985: |
| 2986: |
| 2987: void TestSuite :: AddTestInfo ( TestInfo * test_info ) {/*
test_info_list_.push_back(test_info);
test_indices_.push_back(static_cast<int>(test_indices_.size()));
*/ |
2988: test_info_list_/* test_info_list_.push_back(test_info) */ . push_back ( test_info ) ; |
| 2989: test_indices_ . push_back ( static_cast < int > ( test_indices_ . size ( ) ) ) ; |
| 2990: } |
| 2991: |
| 2992: |
| 2993: void TestSuite :: Run ( ) {/*
if (!should_run_) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->set_current_test_suite(this);
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
// Call both legacy and the new API
repeater->OnTestSuiteStart(*this);
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
repeater->OnTestCaseStart(*this);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()");
start_timestamp_ = internal::GetTimeInMillis();
internal::Timer timer;
for (int i = 0; i < total_test_count(); i++) {
GetMutableTestInfo(i)->Run();
if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {
for (int j = i + 1; j < total_test_count(); j++) {
GetMutableTestInfo(j)->Skip();
}
break;
}
}
elapsed_time_ = timer.Elapsed();
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &TestSuite::RunTearDownTestSuite, "TearDownTestSuite()");
// Call both legacy and the new API
repeater->OnTestSuiteEnd(*this);
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
repeater->OnTestCaseEnd(*this);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
impl->set_current_test_suite(nullptr);
*/ |
2994: if/* if (!should_run_) return */ ! should_run_ ) ; |
| 2995: |
| 2996: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
2997: impl/* impl->set_current_test_suite(this) */ -> set_current_test_suite ( this ) ; |
| 2998: |
| 2999: TestEventListener * repeater = UnitTest :: GetInstance ( ) -> listeners ( ) . repeater ( ) ; |
| 3000: |
| 3001: |
3002: repeater/* repeater->OnTestSuiteStart(*this) */ -> OnTestSuiteStart ( * this ) ; |
| 3003: |
| 3004: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
3005: repeater/* repeater->OnTestCaseStart(*this) */ -> OnTestCaseStart ( * this ) ; |
| 3006: # endif |
| 3007: |
3008: impl/* impl->os_stack_trace_getter()->UponLeavingGTest() */ -> os_stack_trace_getter ( ) -> UponLeavingGTest ( ) ; |
3009: internal/* internal::HandleExceptionsInMethodIfSupported(
this, &TestSuite::RunSetUpTestSuite, "SetUpTestSuite()") */ :: HandleExceptionsInMethodIfSupported ( |
| 3010: this , & TestSuite :: RunSetUpTestSuite , "SetUpTestSuite()" ) ; |
| 3011: |
3012: start_timestamp_/* start_timestamp_ = internal::GetTimeInMillis() */ = internal :: GetTimeInMillis ( ) ; |
| 3013: internal :: Timer timer ; |
3014: for/* for (int i = 0; i < total_test_count(); i++) {
GetMutableTestInfo(i)->Run();
if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {
for (int j = i + 1; j < total_test_count(); j++) {
GetMutableTestInfo(j)->Skip();
}
break;
}
} */ ( int i = 0 ; i < total_test_count ( ) ; i ++ ) {/*
GetMutableTestInfo(i)->Run();
if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {
for (int j = i + 1; j < total_test_count(); j++) {
GetMutableTestInfo(j)->Skip();
}
break;
}
*/ |
3015: GetMutableTestInfo/* GetMutableTestInfo(i)->Run() */ ( i ) -> Run ( ) ; |
3016: if/* if (GTEST_FLAG(fail_fast) && GetMutableTestInfo(i)->result()->Failed()) {
for (int j = i + 1; j < total_test_count(); j++) {
GetMutableTestInfo(j)->Skip();
}
break;
} */ ( GTEST_FLAG ( fail_fast ) GetMutableTestInfo ( i ) -> result ( ) -> Failed ( ) ) {/*
for (int j = i + 1; j < total_test_count(); j++) {
GetMutableTestInfo(j)->Skip();
}
break;
*/ |
3017: for/* for (int j = i + 1; j < total_test_count(); j++) {
GetMutableTestInfo(j)->Skip();
} */ ( int j = i + 1 ; j < total_test_count ( ) ; j ++ ) {/*
GetMutableTestInfo(j)->Skip();
*/ |
3018: GetMutableTestInfo/* GetMutableTestInfo(j)->Skip() */ ( j ) -> Skip ( ) ; |
| 3019: } |
| 3020: break ; |
| 3021: } |
| 3022: } |
3023: elapsed_time_/* elapsed_time_ = timer.Elapsed() */ = timer . Elapsed ( ) ; |
| 3024: |
3025: impl/* impl->os_stack_trace_getter()->UponLeavingGTest() */ -> os_stack_trace_getter ( ) -> UponLeavingGTest ( ) ; |
3026: internal/* internal::HandleExceptionsInMethodIfSupported(
this, &TestSuite::RunTearDownTestSuite, "TearDownTestSuite()") */ :: HandleExceptionsInMethodIfSupported ( |
| 3027: this , & TestSuite :: RunTearDownTestSuite , "TearDownTestSuite()" ) ; |
| 3028: |
| 3029: |
3030: repeater/* repeater->OnTestSuiteEnd(*this) */ -> OnTestSuiteEnd ( * this ) ; |
| 3031: |
| 3032: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
3033: repeater/* repeater->OnTestCaseEnd(*this) */ -> OnTestCaseEnd ( * this ) ; |
| 3034: # endif |
| 3035: |
3036: impl/* impl->set_current_test_suite(nullptr) */ -> set_current_test_suite ( nullptr ) ; |
| 3037: } |
| 3038: |
| 3039: |
| 3040: void TestSuite :: Skip ( ) {/*
if (!should_run_) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->set_current_test_suite(this);
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
// Call both legacy and the new API
repeater->OnTestSuiteStart(*this);
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
repeater->OnTestCaseStart(*this);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
for (int i = 0; i < total_test_count(); i++) {
GetMutableTestInfo(i)->Skip();
}
// Call both legacy and the new API
repeater->OnTestSuiteEnd(*this);
// Legacy API is deprecated but still available
#ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
repeater->OnTestCaseEnd(*this);
#endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
impl->set_current_test_suite(nullptr);
*/ |
3041: if/* if (!should_run_) return */ ! should_run_ ) ; |
| 3042: |
| 3043: internal :: UnitTestImpl * const impl = internal :: GetUnitTestImpl ( ) ; |
3044: impl/* impl->set_current_test_suite(this) */ -> set_current_test_suite ( this ) ; |
| 3045: |
| 3046: TestEventListener * repeater = UnitTest :: GetInstance ( ) -> listeners ( ) . repeater ( ) ; |
| 3047: |
| 3048: |
3049: repeater/* repeater->OnTestSuiteStart(*this) */ -> OnTestSuiteStart ( * this ) ; |
| 3050: |
| 3051: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
3052: repeater/* repeater->OnTestCaseStart(*this) */ -> OnTestCaseStart ( * this ) ; |
| 3053: # endif |
| 3054: |
3055: for/* for (int i = 0; i < total_test_count(); i++) {
GetMutableTestInfo(i)->Skip();
} */ ( int i = 0 ; i < total_test_count ( ) ; i ++ ) {/*
GetMutableTestInfo(i)->Skip();
*/ |
3056: GetMutableTestInfo/* GetMutableTestInfo(i)->Skip() */ ( i ) -> Skip ( ) ; |
| 3057: } |
| 3058: |
| 3059: |
3060: repeater/* repeater->OnTestSuiteEnd(*this) */ -> OnTestSuiteEnd ( * this ) ; |
| 3061: |
| 3062: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
3063: repeater/* repeater->OnTestCaseEnd(*this) */ -> OnTestCaseEnd ( * this ) ; |
| 3064: # endif |
| 3065: |
3066: impl/* impl->set_current_test_suite(nullptr) */ -> set_current_test_suite ( nullptr ) ; |
| 3067: } |
| 3068: |
| 3069: |
| 3070: void TestSuite :: ClearResult ( ) {/*
ad_hoc_test_result_.Clear();
ForEach(test_info_list_, TestInfo::ClearTestResult);
*/ |
3071: ad_hoc_test_result_/* ad_hoc_test_result_.Clear() */ . Clear ( ) ; |
3072: ForEach/* ForEach(test_info_list_, TestInfo::ClearTestResult) */ ( test_info_list_ , TestInfo :: ClearTestResult ) ; |
| 3073: } |
| 3074: |
| 3075: |
| 3076: void TestSuite :: ShuffleTests ( internal :: Random * random ) {/*
Shuffle(random, &test_indices_);
*/ |
3077: Shuffle/* Shuffle(random, &test_indices_) */ ( random , & test_indices_ ) ; |
| 3078: } |
| 3079: |
| 3080: |
| 3081: void TestSuite :: UnshuffleTests ( ) {/*
for (size_t i = 0; i < test_indices_.size(); i++) {
test_indices_[i] = static_cast<int>(i);
}
*/ |
3082: for/* for (size_t i = 0; i < test_indices_.size(); i++) {
test_indices_[i] = static_cast<int>(i);
} */ ( size_t i = 0 ; i < test_indices_ . size ( ) ; i ++ ) {/*
test_indices_[i] = static_cast<int>(i);
*/ |
3083: test_indices_/* test_indices_[i] = static_cast<int>(i) */ [ i ] = static_cast < int > ( i ) ; |
| 3084: } |
| 3085: } |
| 3086: |
| 3087: |
| 3088: |
| 3089: |
| 3090: |
| 3091: |
| 3092: static std :: string FormatCountableNoun ( int count , |
| 3093: const char * singular_form , |
| 3094: const char * plural_form ) { |
| 3095: return internal :: StreamableToString ( count ) + " " + |
| 3096: count == 1 ? singular_form : plural_form ) ; |
| 3097: } |
| 3098: |
| 3099: |
| 3100: static std :: string FormatTestCount ( int test_count ) { |
| 3101: return FormatCountableNoun ( test_count , "test" , "tests" ) ; |
| 3102: } |
| 3103: |
| 3104: |
| 3105: static std :: string FormatTestSuiteCount ( int test_suite_count ) { |
| 3106: return FormatCountableNoun ( test_suite_count , "test suite" , "test suites" ) ; |
| 3107: } |
| 3108: |
| 3109: |
| 3110: |
| 3111: |
| 3112: |
| 3113: static const char * TestPartResultTypeToString ( TestPartResult :: Type type ) { |
| 3114: switch ( type ) { |
| 3115: case TestPartResult :: kSkip : |
| 3116: return "Skipped\n" ; |
| 3117: case TestPartResult :: kSuccess : |
| 3118: return "Success" ; |
| 3119: |
| 3120: case TestPartResult :: kNonFatalFailure : |
| 3121: case TestPartResult :: kFatalFailure : |
| 3122: # ifdef _MSC_VER |
| 3123: return "error: " ; |
| 3124: # else |
| 3125: return "Failure\n" ; |
| 3126: # endif |
| 3127: default : |
| 3128: return "Unknown result type" ; |
| 3129: } |
| 3130: } |
| 3131: |
| 3132: namespace internal { |
| 3133: namespace { |
| 3134: enum class GTestColor { kDefault , kRed , kGreen , kYellow } ; |
| 3135: } |
| 3136: |
| 3137: |
| 3138: static std :: string PrintTestPartResultToString ( |
| 3139: const TestPartResult & test_part_result ) { |
| 3140: return ( Message ( ) |
| 3141: << internal :: FormatFileLocation ( test_part_result . file_name ( ) , |
| 3142: test_part_result . line_number ( ) ) |
| 3143: << " " << TestPartResultTypeToString ( test_part_result . type ( ) ) |
| 3144: << test_part_result . message ( ) ) . GetString ( ) ; |
| 3145: } |
| 3146: |
| 3147: |
| 3148: static void PrintTestPartResult ( const TestPartResult & test_part_result ) {/*
const std::string& result =
PrintTestPartResultToString(test_part_result);
printf("%s\n", result.c_str());
fflush(stdout);
// If the test program runs in Visual Studio or a debugger, the
// following statements add the test part result message to the Output
// window such that the user can double-click on it to jump to the
// corresponding source code location; otherwise they do nothing.
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
// We don't call OutputDebugString*() on Windows Mobile, as printing
// to stdout is done by OutputDebugString() there already - we don't
// want the same message printed twice.
::OutputDebugStringA(result.c_str());
::OutputDebugStringA("\n");
#endif
*/ |
| 3149: const std :: string & result = |
| 3150: PrintTestPartResultToString ( test_part_result ) ; |
3151: printf/* printf("%s\n", result.c_str()) */ ( "%s\n" , result . c_str ( ) ) ; |
3152: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3153: |
| 3154: |
| 3155: |
| 3156: |
| 3157: # if GTEST_OS_WINDOWS && ! GTEST_OS_WINDOWS_MOBILE |
| 3158: |
| 3159: |
| 3160: |
| 3161: :: OutputDebugStringA ( result . c_str ( ) ) ; |
| 3162: :: OutputDebugStringA ( "\n" ) ; |
| 3163: # endif |
| 3164: } |
| 3165: |
| 3166: |
| 3167: # if GTEST_OS_WINDOWS && ! GTEST_OS_WINDOWS_MOBILE && |
| 3168: ! GTEST_OS_WINDOWS_PHONE && ! GTEST_OS_WINDOWS_RT && ! GTEST_OS_WINDOWS_MINGW |
| 3169: |
| 3170: |
| 3171: static WORD GetColorAttribute ( GTestColor color ) { |
| 3172: switch ( color ) { |
| 3173: case GTestColor :: kRed : |
| 3174: return FOREGROUND_RED ; |
| 3175: case GTestColor :: kGreen : |
| 3176: return FOREGROUND_GREEN ; |
| 3177: case GTestColor :: kYellow : |
| 3178: return FOREGROUND_RED | FOREGROUND_GREEN ; |
| 3179: default : return 0 ; |
| 3180: } |
| 3181: } |
| 3182: |
| 3183: static int GetBitOffset ( WORD color_mask ) { |
| 3184: if ( color_mask == 0 ) return 0 ; |
| 3185: |
| 3186: int bitOffset = 0 ; |
| 3187: while ( ( color_mask & 1 ) == 0 ) { |
| 3188: color_mask >>= 1 ; |
| 3189: ++ bitOffset ; |
| 3190: } |
| 3191: return bitOffset ; |
| 3192: } |
| 3193: |
| 3194: static WORD GetNewColor ( GTestColor color , WORD old_color_attrs ) { |
| 3195: |
| 3196: static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | |
| 3197: BACKGROUND_RED | BACKGROUND_INTENSITY ; |
| 3198: static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | |
| 3199: FOREGROUND_RED | FOREGROUND_INTENSITY ; |
| 3200: const WORD existing_bg = old_color_attrs & background_mask ; |
| 3201: |
| 3202: WORD new_color = |
| 3203: GetColorAttribute ( color ) | existing_bg | FOREGROUND_INTENSITY ; |
| 3204: static const int bg_bitOffset = GetBitOffset ( background_mask ) ; |
| 3205: static const int fg_bitOffset = GetBitOffset ( foreground_mask ) ; |
| 3206: |
| 3207: if ( ( ( new_color & background_mask ) >> bg_bitOffset ) == |
| 3208: ( ( new_color & foreground_mask ) >> fg_bitOffset ) ) { |
| 3209: new_color ^= FOREGROUND_INTENSITY ; |
| 3210: } |
| 3211: return new_color ; |
| 3212: } |
| 3213: |
| 3214: # else |
| 3215: |
| 3216: |
| 3217: |
| 3218: static const char * GetAnsiColorCode ( GTestColor color ) { |
| 3219: switch ( color ) { |
| 3220: case GTestColor :: kRed : |
| 3221: return "1" ; |
| 3222: case GTestColor :: kGreen : |
| 3223: return "2" ; |
| 3224: case GTestColor :: kYellow : |
| 3225: return "3" ; |
| 3226: default : |
| 3227: return nullptr ; |
| 3228: } |
| 3229: } |
| 3230: |
| 3231: # endif |
| 3232: |
| 3233: |
| 3234: bool ShouldUseColor ( bool stdout_is_tty ) { |
| 3235: const char * const gtest_color = GTEST_FLAG ( color ) . c_str ( ) ; |
| 3236: |
| 3237: if String :: CaseInsensitiveCStringEquals ( gtest_color , "auto" ) ) { |
| 3238: # if GTEST_OS_WINDOWS && ! GTEST_OS_WINDOWS_MINGW |
| 3239: |
| 3240: |
| 3241: return stdout_is_tty ; |
| 3242: # else |
| 3243: |
| 3244: const char * const term = posix :: GetEnv ( "TERM" ) ; |
| 3245: const bool term_supports_color = |
3246: Stringtruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalse :: CStringEquals ( term , "xterm" ) |
| 3247: String :: CStringEquals ( term , "xterm-color" ) |
| 3248: String :: CStringEquals ( term , "xterm-256color" ) |
| 3249: String :: CStringEquals ( term , "screen" ) |
| 3250: String :: CStringEquals ( term , "screen-256color" ) |
| 3251: String :: CStringEquals ( term , "tmux" ) |
| 3252: String :: CStringEquals ( term , "tmux-256color" ) |
| 3253: String :: CStringEquals ( term , "rxvt-unicode" ) |
| 3254: String :: CStringEquals ( term , "rxvt-unicode-256color" ) |
| 3255: String :: CStringEquals ( term , "linux" ) |
| 3256: String :: CStringEquals ( term , "cygwin" ) ; |
| 3257: return stdout_is_ttytruefalsetruefalsetruefalse term_supports_colortruefalse ; |
| 3258: # endif |
| 3259: } |
| 3260: |
| 3261: return Stringtruefalsetruefalsetruefalsetruefalsetruefalsetruefalse :: CaseInsensitiveCStringEquals ( gtest_color , "yes" ) |
| 3262: String :: CaseInsensitiveCStringEquals ( gtest_color , "true" ) |
| 3263: String :: CaseInsensitiveCStringEquals ( gtest_color , "t" ) |
| 3264: String :: CStringEquals ( gtest_color , "1" ) ; |
| 3265: |
| 3266: |
| 3267: |
| 3268: } |
| 3269: |
| 3270: |
| 3271: |
| 3272: |
| 3273: |
| 3274: |
| 3275: GTEST_ATTRIBUTE_PRINTF_ ( 2 , 3 ) |
| 3276: static void ColoredPrintf ( GTestColor color , const char * fmt , ... ) {/*
va_list args;
va_start(args, fmt);
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \
GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined(ESP_PLATFORM)
const bool use_color = AlwaysFalse();
#else
static const bool in_color_mode =
ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
const bool use_color = in_color_mode && (color != GTestColor::kDefault);
#endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS
if (!use_color) {
vprintf(fmt, args);
va_end(args);
return;
}
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Gets the current text color.
CONSOLE_SCREEN_BUFFER_INFO buffer_info;
GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
const WORD old_color_attrs = buffer_info.wAttributes;
const WORD new_color = GetNewColor(color, old_color_attrs);
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
fflush(stdout);
SetConsoleTextAttribute(stdout_handle, new_color);
vprintf(fmt, args);
fflush(stdout);
// Restores the text color.
SetConsoleTextAttribute(stdout_handle, old_color_attrs);
#else
printf("\033[0;3%sm", GetAnsiColorCode(color));
vprintf(fmt, args);
printf("\033[m"); // Resets the terminal to default.
#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
va_end(args);
*/ |
| 3277: va_list args ; |
| 3278: va_start ( args , fmt ) ; |
| 3279: |
| 3280: # if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || |
| 3281: GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined ( ESP_PLATFORM ) |
| 3282: const bool use_color = AlwaysFalse ( ) ; |
| 3283: # else |
| 3284: static const bool in_color_mode = |
| 3285: ShouldUseColor posix :: IsATTY ( posix :: FileNo ( stdout ) ) != 0 ) ; |
| 3286: const bool use_color = in_color_modetruefalsetruefalse color != GTestColor :: kDefault ) ; |
| 3287: # endif |
| 3288: |
3289: if/* if (!use_color) {
vprintf(fmt, args);
va_end(args);
return;
} */ ! use_color ) {/*
vprintf(fmt, args);
va_end(args);
return;
*/ |
3290: vprintf/* vprintf(fmt, args) */ ( fmt , args ) ; |
| 3291: va_end ( args ) ; |
| 3292: ; |
| 3293: } |
| 3294: |
| 3295: # if GTEST_OS_WINDOWS && ! GTEST_OS_WINDOWS_MOBILE && |
| 3296: ! GTEST_OS_WINDOWS_PHONE && ! GTEST_OS_WINDOWS_RT && ! GTEST_OS_WINDOWS_MINGW |
| 3297: const HANDLE stdout_handle = GetStdHandle ( STD_OUTPUT_HANDLE ) ; |
| 3298: |
| 3299: |
| 3300: CONSOLE_SCREEN_BUFFER_INFO buffer_info ; |
| 3301: GetConsoleScreenBufferInfo ( stdout_handle , & buffer_info ) ; |
| 3302: const WORD old_color_attrs = buffer_info . wAttributes ; |
| 3303: const WORD new_color = GetNewColor ( color , old_color_attrs ) ; |
| 3304: |
| 3305: |
| 3306: |
| 3307: |
| 3308: fflush ( stdout ) ; |
| 3309: SetConsoleTextAttribute ( stdout_handle , new_color ) ; |
| 3310: |
| 3311: vprintf ( fmt , args ) ; |
| 3312: |
| 3313: fflush ( stdout ) ; |
| 3314: |
| 3315: SetConsoleTextAttribute ( stdout_handle , old_color_attrs ) ; |
| 3316: # else |
3317: printf/* printf("\033[0;3%sm", GetAnsiColorCode(color)) */ ( "\033[0;3%sm" , GetAnsiColorCode ( color ) ) ; |
3318: vprintf/* vprintf(fmt, args) */ ( fmt , args ) ; |
3319: printf/* printf("\033[m") */ ( "\033[m" ) ; |
| 3320: # endif |
| 3321: va_end ( args ) ; |
| 3322: } |
| 3323: |
| 3324: |
| 3325: |
| 3326: static const char kTypeParamLabel [ ] = "TypeParam" ; |
| 3327: static const char kValueParamLabel [ ] = "GetParam()" ; |
| 3328: |
| 3329: static void PrintFullTestCommentIfPresent ( const TestInfo & test_info ) {/*
const char* const type_param = test_info.type_param();
const char* const value_param = test_info.value_param();
if (type_param != nullptr || value_param != nullptr) {
printf(", where ");
if (type_param != nullptr) {
printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != nullptr) printf(" and ");
}
if (value_param != nullptr) {
printf("%s = %s", kValueParamLabel, value_param);
}
}
*/ |
| 3330: const char * const type_param = test_info . type_param ( ) ; |
| 3331: const char * const value_param = test_info . value_param ( ) ; |
| 3332: |
3333: if/* if (type_param != nullptr || value_param != nullptr) {
printf(", where ");
if (type_param != nullptr) {
printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != nullptr) printf(" and ");
}
if (value_param != nullptr) {
printf("%s = %s", kValueParamLabel, value_param);
}
} */ (truefalsetruefalsetruefalse type_param != nullptr != nullptr ) {/*
printf(", where ");
if (type_param != nullptr) {
printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != nullptr) printf(" and ");
}
if (value_param != nullptr) {
printf("%s = %s", kValueParamLabel, value_param);
}
*/ |
3334: printf/* printf(", where ") */ ( ", where " ) ; |
3335: if/* if (type_param != nullptr) {
printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != nullptr) printf(" and ");
} */ type_param != nullptr ) {/*
printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != nullptr) printf(" and ");
*/ |
3336: printf/* printf("%s = %s", kTypeParamLabel, type_param) */ ( "%s = %s" , kTypeParamLabel , type_param ) ; |
3337: if/* if (value_param != nullptr) printf(" and ") */ value_param != nullptr ) printf ( " and " ) ; |
| 3338: } |
3339: if/* if (value_param != nullptr) {
printf("%s = %s", kValueParamLabel, value_param);
} */ value_param != nullptr ) {/*
printf("%s = %s", kValueParamLabel, value_param);
*/ |
3340: printf/* printf("%s = %s", kValueParamLabel, value_param) */ ( "%s = %s" , kValueParamLabel , value_param ) ; |
| 3341: } |
| 3342: } |
| 3343: } |
| 3344: |
| 3345: |
| 3346: |
| 3347: |
| 3348: class PrettyUnitTestResultPrinter : public TestEventListener { |
| 3349: public : |
| 3350: PrettyUnitTestResultPrinter ( ) { } |
| 3351: static void PrintTestName ( const char * test_suite , const char * test ) {/*
printf("%s.%s", test_suite, test);
*/ |
3352: printf/* printf("%s.%s", test_suite, test) */ ( "%s.%s" , test_suite , test ) ; |
| 3353: } |
| 3354: |
| 3355: |
| 3356: void OnTestProgramStart ( const UnitTest & ) override { } |
| 3357: void OnTestIterationStart ( const UnitTest & unit_test , int iteration ) override ; |
| 3358: void OnEnvironmentsSetUpStart ( const UnitTest & unit_test ) override ; |
| 3359: void OnEnvironmentsSetUpEnd ( const UnitTest & ) override { } |
| 3360: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3361: void OnTestCaseStart ( const TestCase & test_case ) override ; |
| 3362: # else |
| 3363: void OnTestSuiteStart ( const TestSuite & test_suite ) override ; |
| 3364: # endif |
| 3365: |
| 3366: void OnTestStart ( const TestInfo & test_info ) override ; |
| 3367: |
| 3368: void OnTestPartResult ( const TestPartResult & result ) override ; |
| 3369: void OnTestEnd ( const TestInfo & test_info ) override ; |
| 3370: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3371: void OnTestCaseEnd ( const TestCase & test_case ) override ; |
| 3372: # else |
| 3373: void OnTestSuiteEnd ( const TestSuite & test_suite ) override ; |
| 3374: # endif |
| 3375: |
| 3376: void OnEnvironmentsTearDownStart ( const UnitTest & unit_test ) override ; |
| 3377: void OnEnvironmentsTearDownEnd ( const UnitTest & ) override { } |
| 3378: void OnTestIterationEnd ( const UnitTest & unit_test , int iteration ) override ; |
| 3379: void OnTestProgramEnd ( const UnitTest & ) override { } |
| 3380: |
| 3381: private : |
| 3382: static void PrintFailedTests ( const UnitTest & unit_test ) ; |
| 3383: static void PrintFailedTestSuites ( const UnitTest & unit_test ) ; |
| 3384: static void PrintSkippedTests ( const UnitTest & unit_test ) ; |
| 3385: } ; |
| 3386: |
| 3387: |
| 3388: void PrettyUnitTestResultPrinter :: OnTestIterationStart ( |
| 3389: const UnitTest & unit_test , int iteration ) {/*
if (GTEST_FLAG(repeat) != 1)
printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
const char* const filter = GTEST_FLAG(filter).c_str();
// Prints the filter if it's not *. This reminds the user that some
// tests may be skipped.
if (!String::CStringEquals(filter, kUniversalFilter)) {
ColoredPrintf(GTestColor::kYellow, "Note: %s filter = %s\n", GTEST_NAME_,
filter);
}
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
const int32_t shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
ColoredPrintf(GTestColor::kYellow, "Note: This is test shard %d of %s.\n",
static_cast<int>(shard_index) + 1,
internal::posix::GetEnv(kTestTotalShards));
}
if (GTEST_FLAG(shuffle)) {
ColoredPrintf(GTestColor::kYellow,
"Note: Randomizing tests' orders with a seed of %d .\n",
unit_test.random_seed());
}
ColoredPrintf(GTestColor::kGreen, "[==========] ");
printf("Running %s from %s.\n",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
fflush(stdout);
*/ |
3390: if/* if (GTEST_FLAG(repeat) != 1)
printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1) */ ( GTEST_FLAG ( repeat ) != 1 ) |
| 3391: printf ( "\nRepeating all tests (iteration %d) . . .\n\n" , iteration + 1 ) ; |
| 3392: |
| 3393: const char * const filter = GTEST_FLAG ( filter ) . c_str ( ) ; |
| 3394: |
| 3395: |
| 3396: |
3397: if/* if (!String::CStringEquals(filter, kUniversalFilter)) {
ColoredPrintf(GTestColor::kYellow, "Note: %s filter = %s\n", GTEST_NAME_,
filter);
} */ (truefalse!!String::CStringEquals(filter, kUniversalFilter) ! String :: CStringEquals ( filter , kUniversalFilter ) ) {/*
ColoredPrintf(GTestColor::kYellow, "Note: %s filter = %s\n", GTEST_NAME_,
filter);
*/ |
3398: ColoredPrintf/* ColoredPrintf(GTestColor::kYellow, "Note: %s filter = %s\n", GTEST_NAME_,
filter) */ ( GTestColor :: kYellow , "Note: %s filter = %s\n" , GTEST_NAME_ , |
| 3399: filter ) ; |
| 3400: } |
| 3401: |
3402: if/* if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
const int32_t shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
ColoredPrintf(GTestColor::kYellow, "Note: This is test shard %d of %s.\n",
static_cast<int>(shard_index) + 1,
internal::posix::GetEnv(kTestTotalShards));
} */ internal :: ShouldShard ( kTestTotalShards , kTestShardIndex , false ) ) {/*
const int32_t shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
ColoredPrintf(GTestColor::kYellow, "Note: This is test shard %d of %s.\n",
static_cast<int>(shard_index) + 1,
internal::posix::GetEnv(kTestTotalShards));
*/ |
| 3403: const int32_t shard_index = Int32FromEnvOrDie ( kTestShardIndex , - 1 ) ; |
3404: ColoredPrintf/* ColoredPrintf(GTestColor::kYellow, "Note: This is test shard %d of %s.\n",
static_cast<int>(shard_index) + 1,
internal::posix::GetEnv(kTestTotalShards)) */ ( GTestColor :: kYellow , "Note: This is test shard %d of %s.\n" , |
| 3405: static_cast < int > ( shard_index ) + 1 , |
| 3406: internal :: posix :: GetEnv ( kTestTotalShards ) ) ; |
| 3407: } |
| 3408: |
3409: if/* if (GTEST_FLAG(shuffle)) {
ColoredPrintf(GTestColor::kYellow,
"Note: Randomizing tests' orders with a seed of %d .\n",
unit_test.random_seed());
} */ ( GTEST_FLAG ( shuffle ) ) {/*
ColoredPrintf(GTestColor::kYellow,
"Note: Randomizing tests' orders with a seed of %d .\n",
unit_test.random_seed());
*/ |
3410: ColoredPrintf/* ColoredPrintf(GTestColor::kYellow,
"Note: Randomizing tests' orders with a seed of %d .\n",
unit_test.random_seed()) */ ( GTestColor :: kYellow , |
| 3411: "Note: Randomizing tests' orders with a seed of %d .\n" , |
| 3412: unit_test . random_seed ( ) ) ; |
| 3413: } |
| 3414: |
3415: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[==========] ") */ ( GTestColor :: kGreen , "[==========] " ) ; |
| 3416: printf ( "Running %s from %s.\n" , |
| 3417: FormatTestCount ( unit_test . test_to_run_count ( ) ) . c_str ( ) , |
| 3418: FormatTestSuiteCount ( unit_test . test_suite_to_run_count ( ) ) . c_str ( ) ) ; |
3419: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3420: } |
| 3421: |
| 3422: void PrettyUnitTestResultPrinter :: OnEnvironmentsSetUpStart ( |
| 3423: const UnitTest & ) {/*
ColoredPrintf(GTestColor::kGreen, "[----------] ");
printf("Global test environment set-up.\n");
fflush(stdout);
*/ |
3424: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[----------] ") */ ( GTestColor :: kGreen , "[----------] " ) ; |
3425: printf/* printf("Global test environment set-up.\n") */ ( "Global test environment set-up.\n" ) ; |
3426: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3427: } |
| 3428: |
| 3429: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3430: void PrettyUnitTestResultPrinter :: OnTestCaseStart ( const TestCase & test_case ) {/*
const std::string counts =
FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
ColoredPrintf(GTestColor::kGreen, "[----------] ");
printf("%s from %s", counts.c_str(), test_case.name());
if (test_case.type_param() == nullptr) {
printf("\n");
} else {
printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
}
fflush(stdout);
*/ |
| 3431: const std :: string counts = |
| 3432: FormatCountableNoun ( test_case . test_to_run_count ( ) , "test" , "tests" ) ; |
3433: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[----------] ") */ ( GTestColor :: kGreen , "[----------] " ) ; |
3434: printf/* printf("%s from %s", counts.c_str(), test_case.name()) */ ( "%s from %s" , counts . c_str ( ) , test_case . name ( ) ) ; |
3435: if/* if (test_case.type_param() == nullptr) {
printf("\n");
} else {
printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
} */ test_case . type_param ( ) == nullptr ) |
| 3436: ( "\n" ) ; |
| 3437: } else {/*
printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
*/ |
3438: printf/* printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param()) */ ( ", where %s = %s\n" , kTypeParamLabel , test_case . type_param ( ) ) ; |
| 3439: } |
3440: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3441: } |
| 3442: # else |
| 3443: void PrettyUnitTestResultPrinter :: OnTestSuiteStart ( |
| 3444: const TestSuite & test_suite ) { |
| 3445: const std :: string counts = |
| 3446: FormatCountableNoun ( test_suite . test_to_run_count ( ) , "test" , "tests" ) ; |
| 3447: ColoredPrintf ( GTestColor :: kGreen , "[----------] " ) ; |
| 3448: printf ( "%s from %s" , counts . c_str ( ) , test_suite . name ( ) ) ; |
| 3449: if ( test_suite . type_param ( ) == nullptr ) { |
| 3450: printf ( "\n" ) ; |
| 3451: } else { |
| 3452: printf ( ", where %s = %s\n" , kTypeParamLabel , test_suite . type_param ( ) ) ; |
| 3453: } |
| 3454: fflush ( stdout ) ; |
| 3455: } |
| 3456: # endif |
| 3457: |
| 3458: void PrettyUnitTestResultPrinter :: OnTestStart ( const TestInfo & test_info ) {/*
ColoredPrintf(GTestColor::kGreen, "[ RUN ] ");
PrintTestName(test_info.test_suite_name(), test_info.name());
printf("\n");
fflush(stdout);
*/ |
3459: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ RUN ] ") */ ( GTestColor :: kGreen , "[ RUN ] " ) ; |
3460: PrintTestName/* PrintTestName(test_info.test_suite_name(), test_info.name()) */ ( test_info . test_suite_name ( ) , test_info . name ( ) ) ; |
| 3461: ( "\n" ) ; |
3462: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3463: } |
| 3464: |
| 3465: |
| 3466: void PrettyUnitTestResultPrinter :: OnTestPartResult ( |
| 3467: const TestPartResult & result ) {/*
switch (result.type()) {
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
default:
// Print failure message from the assertion
// (e.g. expected this and got that).
PrintTestPartResult(result);
fflush(stdout);
}
*/ |
3468: switch/* switch (result.type()) {
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
default:
// Print failure message from the assertion
// (e.g. expected this and got that).
PrintTestPartResult(result);
fflush(stdout);
} */ ( result . type ( ) ) { |
| 3469: |
| 3470: case TestPartResult :: kSuccess : |
| 3471: ; |
| 3472: default : |
| 3473: |
| 3474: |
3475: PrintTestPartResult/* PrintTestPartResult(result) */ ( result ) ; |
3476: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3477: } |
| 3478: } |
| 3479: |
| 3480: void PrettyUnitTestResultPrinter :: OnTestEnd ( const TestInfo & test_info ) {/*
if (test_info.result()->Passed()) {
ColoredPrintf(GTestColor::kGreen, "[ OK ] ");
} else if (test_info.result()->Skipped()) {
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
} else {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
}
PrintTestName(test_info.test_suite_name(), test_info.name());
if (test_info.result()->Failed())
PrintFullTestCommentIfPresent(test_info);
if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n", internal::StreamableToString(
test_info.result()->elapsed_time()).c_str());
} else {
printf("\n");
}
fflush(stdout);
*/ |
3481: if/* if (test_info.result()->Passed()) {
ColoredPrintf(GTestColor::kGreen, "[ OK ] ");
} else if (test_info.result()->Skipped()) {
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
} else {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
} */ test_info . result ( ) -> Passed ( ) ) {/*
ColoredPrintf(GTestColor::kGreen, "[ OK ] ");
*/ |
3482: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ OK ] ") */ ( GTestColor :: kGreen , "[ OK ] " ) ; |
| 3483: } else if/* if (test_info.result()->Skipped()) {
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
} else {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
} */ test_info . result ( ) -> Skipped ( ) ) {/*
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
*/ |
3484: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ") */ ( GTestColor :: kGreen , "[ SKIPPED ] " ) ; |
| 3485: } else {/*
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
*/ |
3486: ColoredPrintf/* ColoredPrintf(GTestColor::kRed, "[ FAILED ] ") */ ( GTestColor :: kRed , "[ FAILED ] " ) ; |
| 3487: } |
3488: PrintTestName/* PrintTestName(test_info.test_suite_name(), test_info.name()) */ ( test_info . test_suite_name ( ) , test_info . name ( ) ) ; |
3489: if/* if (test_info.result()->Failed())
PrintFullTestCommentIfPresent(test_info) */ test_info . result ( ) -> Failed ( ) ) |
| 3490: PrintFullTestCommentIfPresent ( test_info ) ; |
| 3491: |
3492: if/* if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n", internal::StreamableToString(
test_info.result()->elapsed_time()).c_str());
} else {
printf("\n");
} */ ( GTEST_FLAG ( print_time ) ) {/*
printf(" (%s ms)\n", internal::StreamableToString(
test_info.result()->elapsed_time()).c_str());
*/ |
| 3493: printf ( " (%s ms)\n" , internal :: StreamableToString ( |
| 3494: test_info . result ( ) -> elapsed_time ( ) ) . c_str ( ) ) ; |
| 3495: } else |
| 3496: ( "\n" ) ; |
| 3497: } |
3498: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3499: } |
| 3500: |
| 3501: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3502: void PrettyUnitTestResultPrinter :: OnTestCaseEnd ( const TestCase & test_case ) {/*
if (!GTEST_FLAG(print_time)) return;
const std::string counts =
FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
ColoredPrintf(GTestColor::kGreen, "[----------] ");
printf("%s from %s (%s ms total)\n\n", counts.c_str(), test_case.name(),
internal::StreamableToString(test_case.elapsed_time()).c_str());
fflush(stdout);
*/ |
3503: if/* if (!GTEST_FLAG(print_time)) return */ (truefalse!!GTEST_FLAG(print_time) ! GTEST_FLAG ( print_time ) ) ; |
| 3504: |
| 3505: const std :: string counts = |
| 3506: FormatCountableNoun ( test_case . test_to_run_count ( ) , "test" , "tests" ) ; |
3507: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[----------] ") */ ( GTestColor :: kGreen , "[----------] " ) ; |
| 3508: printf ( "%s from %s (%s ms total)\n\n" , counts . c_str ( ) , test_case . name ( ) , |
| 3509: internal :: StreamableToString ( test_case . elapsed_time ( ) ) . c_str ( ) ) ; |
3510: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3511: } |
| 3512: # else |
| 3513: void PrettyUnitTestResultPrinter :: OnTestSuiteEnd ( const TestSuite & test_suite ) { |
| 3514: if ( ! GTEST_FLAG ( print_time ) ) return ; |
| 3515: |
| 3516: const std :: string counts = |
| 3517: FormatCountableNoun ( test_suite . test_to_run_count ( ) , "test" , "tests" ) ; |
| 3518: ColoredPrintf ( GTestColor :: kGreen , "[----------] " ) ; |
| 3519: printf ( "%s from %s (%s ms total)\n\n" , counts . c_str ( ) , test_suite . name ( ) , |
| 3520: internal :: StreamableToString ( test_suite . elapsed_time ( ) ) . c_str ( ) ) ; |
| 3521: fflush ( stdout ) ; |
| 3522: } |
| 3523: # endif |
| 3524: |
| 3525: void PrettyUnitTestResultPrinter :: OnEnvironmentsTearDownStart ( |
| 3526: const UnitTest & ) {/*
ColoredPrintf(GTestColor::kGreen, "[----------] ");
printf("Global test environment tear-down\n");
fflush(stdout);
*/ |
3527: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[----------] ") */ ( GTestColor :: kGreen , "[----------] " ) ; |
3528: printf/* printf("Global test environment tear-down\n") */ ( "Global test environment tear-down\n" ) ; |
3529: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3530: } |
| 3531: |
| 3532: |
| 3533: void PrettyUnitTestResultPrinter :: PrintFailedTests ( const UnitTest & unit_test ) {/*
const int failed_test_count = unit_test.failed_test_count();
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str());
for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run() || (test_suite.failed_test_count() == 0)) {
continue;
}
for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Failed()) {
continue;
}
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
printf("\n");
}
}
printf("\n%2d FAILED %s\n", failed_test_count,
failed_test_count == 1 ? "TEST" : "TESTS");
*/ |
| 3534: const int failed_test_count = unit_test . failed_test_count ( ) ; |
3535: ColoredPrintf/* ColoredPrintf(GTestColor::kRed, "[ FAILED ] ") */ ( GTestColor :: kRed , "[ FAILED ] " ) ; |
| 3536: printf ( "%s, listed below:\n" , FormatTestCount ( failed_test_count ) . c_str ( ) ) ; |
| 3537: |
3538: for/* for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run() || (test_suite.failed_test_count() == 0)) {
continue;
}
for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Failed()) {
continue;
}
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
printf("\n");
}
} */ ( int i = 0 ; i < unit_test . total_test_suite_count ( ) ; ++ i ) {/*
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run() || (test_suite.failed_test_count() == 0)) {
continue;
}
for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Failed()) {
continue;
}
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
printf("\n");
}
*/ |
| 3539: const TestSuite & test_suite = * unit_test . GetTestSuite ( i ) ; |
3540: if/* if (!test_suite.should_run() || (test_suite.failed_test_count() == 0)) {
continue;
} */ (!!test_suite.should_run()truefalsetruefalse ! test_suite . should_run ( ) test_suite . failed_test_count ( ) == 0 ) ) { |
| 3541: continue ; |
| 3542: } |
3543: for/* for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Failed()) {
continue;
}
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
printf("\n");
} */ ( int j = 0 ; j < test_suite . total_test_count ( ) ; ++ j ) {/*
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Failed()) {
continue;
}
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
printf("\n");
*/ |
| 3544: const TestInfo & test_info = * test_suite . GetTestInfo ( j ) ; |
3545: if/* if (!test_info.should_run() || !test_info.result()->Failed()) {
continue;
} */ (!!test_info.should_run()truefalsetruefalse ! test_info . should_run ( ) !!!test_info.result()->Failed() test_info . result ( ) -> Failed ( ) ) { |
| 3546: continue ; |
| 3547: } |
3548: ColoredPrintf/* ColoredPrintf(GTestColor::kRed, "[ FAILED ] ") */ ( GTestColor :: kRed , "[ FAILED ] " ) ; |
3549: printf/* printf("%s.%s", test_suite.name(), test_info.name()) */ ( "%s.%s" , test_suite . name ( ) , test_info . name ( ) ) ; |
3550: PrintFullTestCommentIfPresent/* PrintFullTestCommentIfPresent(test_info) */ ( test_info ) ; |
| 3551: ( "\n" ) ; |
| 3552: } |
| 3553: } |
3554: printf/* printf("\n%2d FAILED %s\n", failed_test_count,
failed_test_count == 1 ? "TEST" : "TESTS") */ ( "\n%2d FAILED %s\n" , failed_test_count , |
3555: failed_test_counttruefalse == 1 ? "TEST" : "TESTS" ) ; |
| 3556: } |
| 3557: |
| 3558: |
| 3559: |
| 3560: void PrettyUnitTestResultPrinter :: PrintFailedTestSuites ( |
| 3561: const UnitTest & unit_test ) {/*
int suite_failure_count = 0;
for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run()) {
continue;
}
if (test_suite.ad_hoc_test_result().Failed()) {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s: SetUpTestSuite or TearDownTestSuite\n", test_suite.name());
++suite_failure_count;
}
}
if (suite_failure_count > 0) {
printf("\n%2d FAILED TEST %s\n", suite_failure_count,
suite_failure_count == 1 ? "SUITE" : "SUITES");
}
*/ |
| 3562: int suite_failure_count = 0 ; |
3563: for/* for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run()) {
continue;
}
if (test_suite.ad_hoc_test_result().Failed()) {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s: SetUpTestSuite or TearDownTestSuite\n", test_suite.name());
++suite_failure_count;
}
} */ ( int i = 0 ; i < unit_test . total_test_suite_count ( ) ; ++ i ) {/*
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run()) {
continue;
}
if (test_suite.ad_hoc_test_result().Failed()) {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s: SetUpTestSuite or TearDownTestSuite\n", test_suite.name());
++suite_failure_count;
}
*/ |
| 3564: const TestSuite & test_suite = * unit_test . GetTestSuite ( i ) ; |
3565: if/* if (!test_suite.should_run()) {
continue;
} */ (truefalse!!test_suite.should_run() ! test_suite . should_run ( ) ) { |
| 3566: continue ; |
| 3567: } |
3568: if/* if (test_suite.ad_hoc_test_result().Failed()) {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s: SetUpTestSuite or TearDownTestSuite\n", test_suite.name());
++suite_failure_count;
} */ test_suite . ad_hoc_test_result ( ) . Failed ( ) ) {/*
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
printf("%s: SetUpTestSuite or TearDownTestSuite\n", test_suite.name());
++suite_failure_count;
*/ |
3569: ColoredPrintf/* ColoredPrintf(GTestColor::kRed, "[ FAILED ] ") */ ( GTestColor :: kRed , "[ FAILED ] " ) ; |
3570: printf/* printf("%s: SetUpTestSuite or TearDownTestSuite\n", test_suite.name()) */ ( "%s: SetUpTestSuite or TearDownTestSuite\n" , test_suite . name ( ) ) ; |
3571: ++/* ++suite_failure_count */ suite_failure_count ; |
| 3572: } |
| 3573: } |
3574: if/* if (suite_failure_count > 0) {
printf("\n%2d FAILED TEST %s\n", suite_failure_count,
suite_failure_count == 1 ? "SUITE" : "SUITES");
} */ suite_failure_count > 0 ) {/*
printf("\n%2d FAILED TEST %s\n", suite_failure_count,
suite_failure_count == 1 ? "SUITE" : "SUITES");
*/ |
3575: printf/* printf("\n%2d FAILED TEST %s\n", suite_failure_count,
suite_failure_count == 1 ? "SUITE" : "SUITES") */ ( "\n%2d FAILED TEST %s\n" , suite_failure_count , |
3576: suite_failure_counttruefalse == 1 ? "SUITE" : "SUITES" ) ; |
| 3577: } |
| 3578: } |
| 3579: |
| 3580: |
| 3581: void PrettyUnitTestResultPrinter :: PrintSkippedTests ( const UnitTest & unit_test ) {/*
const int skipped_test_count = unit_test.skipped_test_count();
if (skipped_test_count == 0) {
return;
}
for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run() || (test_suite.skipped_test_count() == 0)) {
continue;
}
for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Skipped()) {
continue;
}
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
printf("\n");
}
}
*/ |
| 3582: const int skipped_test_count = unit_test . skipped_test_count ( ) ; |
3583: if/* if (skipped_test_count == 0) {
return;
} */ skipped_test_count == 0 ) |
| 3584: ; |
| 3585: } |
| 3586: |
3587: for/* for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run() || (test_suite.skipped_test_count() == 0)) {
continue;
}
for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Skipped()) {
continue;
}
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
printf("\n");
}
} */ ( int i = 0 ; i < unit_test . total_test_suite_count ( ) ; ++ i ) {/*
const TestSuite& test_suite = *unit_test.GetTestSuite(i);
if (!test_suite.should_run() || (test_suite.skipped_test_count() == 0)) {
continue;
}
for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Skipped()) {
continue;
}
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
printf("\n");
}
*/ |
| 3588: const TestSuite & test_suite = * unit_test . GetTestSuite ( i ) ; |
3589: if/* if (!test_suite.should_run() || (test_suite.skipped_test_count() == 0)) {
continue;
} */ (!!test_suite.should_run()truefalsetruefalse ! test_suite . should_run ( ) test_suite . skipped_test_count ( ) == 0 ) ) { |
| 3590: continue ; |
| 3591: } |
3592: for/* for (int j = 0; j < test_suite.total_test_count(); ++j) {
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Skipped()) {
continue;
}
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
printf("\n");
} */ ( int j = 0 ; j < test_suite . total_test_count ( ) ; ++ j ) {/*
const TestInfo& test_info = *test_suite.GetTestInfo(j);
if (!test_info.should_run() || !test_info.result()->Skipped()) {
continue;
}
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.%s", test_suite.name(), test_info.name());
printf("\n");
*/ |
| 3593: const TestInfo & test_info = * test_suite . GetTestInfo ( j ) ; |
3594: if/* if (!test_info.should_run() || !test_info.result()->Skipped()) {
continue;
} */ (!!test_info.should_run()truefalsetruefalse ! test_info . should_run ( ) !!!test_info.result()->Skipped() test_info . result ( ) -> Skipped ( ) ) { |
| 3595: continue ; |
| 3596: } |
3597: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ") */ ( GTestColor :: kGreen , "[ SKIPPED ] " ) ; |
3598: printf/* printf("%s.%s", test_suite.name(), test_info.name()) */ ( "%s.%s" , test_suite . name ( ) , test_info . name ( ) ) ; |
| 3599: ( "\n" ) ; |
| 3600: } |
| 3601: } |
| 3602: } |
| 3603: |
| 3604: void PrettyUnitTestResultPrinter :: OnTestIterationEnd ( const UnitTest & unit_test , |
| 3605: int ) {/*
ColoredPrintf(GTestColor::kGreen, "[==========] ");
printf("%s from %s ran.",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
if (GTEST_FLAG(print_time)) {
printf(" (%s ms total)",
internal::StreamableToString(unit_test.elapsed_time()).c_str());
}
printf("\n");
ColoredPrintf(GTestColor::kGreen, "[ PASSED ] ");
printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
const int skipped_test_count = unit_test.skipped_test_count();
if (skipped_test_count > 0) {
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s, listed below:\n", FormatTestCount(skipped_test_count).c_str());
PrintSkippedTests(unit_test);
}
if (!unit_test.Passed()) {
PrintFailedTests(unit_test);
PrintFailedTestSuites(unit_test);
}
int num_disabled = unit_test.reportable_disabled_test_count();
if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
}
// Ensure that Google Test output is printed before, e.g., heapchecker output.
fflush(stdout);
*/ |
3606: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[==========] ") */ ( GTestColor :: kGreen , "[==========] " ) ; |
| 3607: printf ( "%s from %s ran." , |
| 3608: FormatTestCount ( unit_test . test_to_run_count ( ) ) . c_str ( ) , |
| 3609: FormatTestSuiteCount ( unit_test . test_suite_to_run_count ( ) ) . c_str ( ) ) ; |
3610: if/* if (GTEST_FLAG(print_time)) {
printf(" (%s ms total)",
internal::StreamableToString(unit_test.elapsed_time()).c_str());
} */ ( GTEST_FLAG ( print_time ) ) {/*
printf(" (%s ms total)",
internal::StreamableToString(unit_test.elapsed_time()).c_str());
*/ |
| 3611: printf ( " (%s ms total)" , |
| 3612: internal :: StreamableToString ( unit_test . elapsed_time ( ) ) . c_str ( ) ) ; |
| 3613: } |
| 3614: ( "\n" ) ; |
3615: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ PASSED ] ") */ ( GTestColor :: kGreen , "[ PASSED ] " ) ; |
| 3616: printf ( "%s.\n" , FormatTestCount ( unit_test . successful_test_count ( ) ) . c_str ( ) ) ; |
| 3617: |
| 3618: const int skipped_test_count = unit_test . skipped_test_count ( ) ; |
3619: if/* if (skipped_test_count > 0) {
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s, listed below:\n", FormatTestCount(skipped_test_count).c_str());
PrintSkippedTests(unit_test);
} */ skipped_test_count > 0 ) {/*
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s, listed below:\n", FormatTestCount(skipped_test_count).c_str());
PrintSkippedTests(unit_test);
*/ |
3620: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ") */ ( GTestColor :: kGreen , "[ SKIPPED ] " ) ; |
| 3621: printf ( "%s, listed below:\n" , FormatTestCount ( skipped_test_count ) . c_str ( ) ) ; |
3622: PrintSkippedTests/* PrintSkippedTests(unit_test) */ ( unit_test ) ; |
| 3623: } |
| 3624: |
3625: if/* if (!unit_test.Passed()) {
PrintFailedTests(unit_test);
PrintFailedTestSuites(unit_test);
} */ (truefalse!!unit_test.Passed() ! unit_test . Passed ( ) ) {/*
PrintFailedTests(unit_test);
PrintFailedTestSuites(unit_test);
*/ |
3626: PrintFailedTests/* PrintFailedTests(unit_test) */ ( unit_test ) ; |
3627: PrintFailedTestSuites/* PrintFailedTestSuites(unit_test) */ ( unit_test ) ; |
| 3628: } |
| 3629: |
| 3630: int num_disabled = unit_test . reportable_disabled_test_count ( ) ; |
3631: if/* if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
} */ num_disabled !!!GTEST_FLAG(also_run_disabled_tests) GTEST_FLAG ( also_run_disabled_tests ) ) {/*
if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
*/ |
3632: if/* if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
} */ unit_test . Passed ( ) ) {/*
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
*/ |
| 3633: ( "\n" ) ; |
| 3634: } |
3635: ColoredPrintf/* ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS") */ ( GTestColor :: kYellow , " YOU HAVE %d DISABLED %s\n\n" , |
| 3636: num_disabled , == 1 ? "TEST" : "TESTS" ) ; |
| 3637: } |
| 3638: |
3639: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3640: } |
| 3641: |
| 3642: |
| 3643: |
| 3644: |
| 3645: |
| 3646: |
| 3647: class BriefUnitTestResultPrinter : public TestEventListener { |
| 3648: public : |
| 3649: BriefUnitTestResultPrinter ( ) { } |
| 3650: static void PrintTestName ( const char * test_suite , const char * test ) {/*
printf("%s.%s", test_suite, test);
*/ |
3651: printf/* printf("%s.%s", test_suite, test) */ ( "%s.%s" , test_suite , test ) ; |
| 3652: } |
| 3653: |
| 3654: |
| 3655: void OnTestProgramStart ( const UnitTest & ) override { } |
| 3656: void OnTestIterationStart ( const UnitTest & , |
| 3657: int ) override { } |
| 3658: void OnEnvironmentsSetUpStart ( const UnitTest & ) override { } |
| 3659: void OnEnvironmentsSetUpEnd ( const UnitTest & ) override { } |
| 3660: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3661: void OnTestCaseStart ( const TestCase & ) override { } |
| 3662: # else |
| 3663: void OnTestSuiteStart ( const TestSuite & ) override { } |
| 3664: # endif |
| 3665: |
| 3666: void OnTestStart ( const TestInfo & ) override { } |
| 3667: |
| 3668: void OnTestPartResult ( const TestPartResult & result ) override ; |
| 3669: void OnTestEnd ( const TestInfo & test_info ) override ; |
| 3670: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3671: void OnTestCaseEnd ( const TestCase & ) override { } |
| 3672: # else |
| 3673: void OnTestSuiteEnd ( const TestSuite & ) override { } |
| 3674: # endif |
| 3675: |
| 3676: void OnEnvironmentsTearDownStart ( const UnitTest & ) override { } |
| 3677: void OnEnvironmentsTearDownEnd ( const UnitTest & ) override { } |
| 3678: void OnTestIterationEnd ( const UnitTest & unit_test , int iteration ) override ; |
| 3679: void OnTestProgramEnd ( const UnitTest & ) override { } |
| 3680: } ; |
| 3681: |
| 3682: |
| 3683: void BriefUnitTestResultPrinter :: OnTestPartResult ( |
| 3684: const TestPartResult & result ) {/*
switch (result.type()) {
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
default:
// Print failure message from the assertion
// (e.g. expected this and got that).
PrintTestPartResult(result);
fflush(stdout);
}
*/ |
3685: switch/* switch (result.type()) {
// If the test part succeeded, we don't need to do anything.
case TestPartResult::kSuccess:
return;
default:
// Print failure message from the assertion
// (e.g. expected this and got that).
PrintTestPartResult(result);
fflush(stdout);
} */ ( result . type ( ) ) { |
| 3686: |
| 3687: case TestPartResult :: kSuccess : |
| 3688: ; |
| 3689: default : |
| 3690: |
| 3691: |
3692: PrintTestPartResult/* PrintTestPartResult(result) */ ( result ) ; |
3693: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3694: } |
| 3695: } |
| 3696: |
| 3697: void BriefUnitTestResultPrinter :: OnTestEnd ( const TestInfo & test_info ) {/*
if (test_info.result()->Failed()) {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
PrintTestName(test_info.test_suite_name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n",
internal::StreamableToString(test_info.result()->elapsed_time())
.c_str());
} else {
printf("\n");
}
fflush(stdout);
}
*/ |
3698: if/* if (test_info.result()->Failed()) {
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
PrintTestName(test_info.test_suite_name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n",
internal::StreamableToString(test_info.result()->elapsed_time())
.c_str());
} else {
printf("\n");
}
fflush(stdout);
} */ test_info . result ( ) -> Failed ( ) ) {/*
ColoredPrintf(GTestColor::kRed, "[ FAILED ] ");
PrintTestName(test_info.test_suite_name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n",
internal::StreamableToString(test_info.result()->elapsed_time())
.c_str());
} else {
printf("\n");
}
fflush(stdout);
*/ |
3699: ColoredPrintf/* ColoredPrintf(GTestColor::kRed, "[ FAILED ] ") */ ( GTestColor :: kRed , "[ FAILED ] " ) ; |
3700: PrintTestName/* PrintTestName(test_info.test_suite_name(), test_info.name()) */ ( test_info . test_suite_name ( ) , test_info . name ( ) ) ; |
3701: PrintFullTestCommentIfPresent/* PrintFullTestCommentIfPresent(test_info) */ ( test_info ) ; |
| 3702: |
3703: if/* if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n",
internal::StreamableToString(test_info.result()->elapsed_time())
.c_str());
} else {
printf("\n");
} */ ( GTEST_FLAG ( print_time ) ) {/*
printf(" (%s ms)\n",
internal::StreamableToString(test_info.result()->elapsed_time())
.c_str());
*/ |
| 3704: printf ( " (%s ms)\n" , |
| 3705: internal :: StreamableToString ( test_info . result ( ) -> elapsed_time ( ) ) |
| 3706: . c_str ( ) ) ; |
| 3707: } else |
| 3708: ( "\n" ) ; |
| 3709: } |
3710: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3711: } |
| 3712: } |
| 3713: |
| 3714: void BriefUnitTestResultPrinter :: OnTestIterationEnd ( const UnitTest & unit_test , |
| 3715: int ) {/*
ColoredPrintf(GTestColor::kGreen, "[==========] ");
printf("%s from %s ran.",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
FormatTestSuiteCount(unit_test.test_suite_to_run_count()).c_str());
if (GTEST_FLAG(print_time)) {
printf(" (%s ms total)",
internal::StreamableToString(unit_test.elapsed_time()).c_str());
}
printf("\n");
ColoredPrintf(GTestColor::kGreen, "[ PASSED ] ");
printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
const int skipped_test_count = unit_test.skipped_test_count();
if (skipped_test_count > 0) {
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.\n", FormatTestCount(skipped_test_count).c_str());
}
int num_disabled = unit_test.reportable_disabled_test_count();
if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
}
// Ensure that Google Test output is printed before, e.g., heapchecker output.
fflush(stdout);
*/ |
3716: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[==========] ") */ ( GTestColor :: kGreen , "[==========] " ) ; |
| 3717: printf ( "%s from %s ran." , |
| 3718: FormatTestCount ( unit_test . test_to_run_count ( ) ) . c_str ( ) , |
| 3719: FormatTestSuiteCount ( unit_test . test_suite_to_run_count ( ) ) . c_str ( ) ) ; |
3720: if/* if (GTEST_FLAG(print_time)) {
printf(" (%s ms total)",
internal::StreamableToString(unit_test.elapsed_time()).c_str());
} */ ( GTEST_FLAG ( print_time ) ) {/*
printf(" (%s ms total)",
internal::StreamableToString(unit_test.elapsed_time()).c_str());
*/ |
| 3721: printf ( " (%s ms total)" , |
| 3722: internal :: StreamableToString ( unit_test . elapsed_time ( ) ) . c_str ( ) ) ; |
| 3723: } |
| 3724: ( "\n" ) ; |
3725: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ PASSED ] ") */ ( GTestColor :: kGreen , "[ PASSED ] " ) ; |
| 3726: printf ( "%s.\n" , FormatTestCount ( unit_test . successful_test_count ( ) ) . c_str ( ) ) ; |
| 3727: |
| 3728: const int skipped_test_count = unit_test . skipped_test_count ( ) ; |
3729: if/* if (skipped_test_count > 0) {
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.\n", FormatTestCount(skipped_test_count).c_str());
} */ skipped_test_count > 0 ) {/*
ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ");
printf("%s.\n", FormatTestCount(skipped_test_count).c_str());
*/ |
3730: ColoredPrintf/* ColoredPrintf(GTestColor::kGreen, "[ SKIPPED ] ") */ ( GTestColor :: kGreen , "[ SKIPPED ] " ) ; |
| 3731: printf ( "%s.\n" , FormatTestCount ( skipped_test_count ) . c_str ( ) ) ; |
| 3732: } |
| 3733: |
| 3734: int num_disabled = unit_test . reportable_disabled_test_count ( ) ; |
3735: if/* if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
} */ num_disabled !!!GTEST_FLAG(also_run_disabled_tests) GTEST_FLAG ( also_run_disabled_tests ) ) {/*
if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS");
*/ |
3736: if/* if (unit_test.Passed()) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
} */ unit_test . Passed ( ) ) {/*
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
*/ |
| 3737: ( "\n" ) ; |
| 3738: } |
3739: ColoredPrintf/* ColoredPrintf(GTestColor::kYellow, " YOU HAVE %d DISABLED %s\n\n",
num_disabled, num_disabled == 1 ? "TEST" : "TESTS") */ ( GTestColor :: kYellow , " YOU HAVE %d DISABLED %s\n\n" , |
| 3740: num_disabled , == 1 ? "TEST" : "TESTS" ) ; |
| 3741: } |
| 3742: |
3743: fflush/* fflush(stdout) */ ( stdout ) ; |
| 3744: } |
| 3745: |
| 3746: |
| 3747: |
| 3748: |
| 3749: |
| 3750: |
| 3751: class TestEventRepeater : public TestEventListener { |
| 3752: public : |
| 3753: TestEventRepeater ( ) : forwarding_enabled_ ( true ) { } |
| 3754: ~ TestEventRepeater ( ) override ; |
| 3755: void Append ( TestEventListener * listener ) ; |
| 3756: TestEventListener * Release ( TestEventListener * listener ) ; |
| 3757: |
| 3758: |
| 3759: |
| 3760: bool forwarding_enabled ( ) const { return forwarding_enabled_truefalse ; } |
| 3761: void set_forwarding_enabled ( bool enable ) {/* forwarding_enabled_ = enable; */ forwarding_enabled_/* forwarding_enabled_ = enable */ = enable ; } |
| 3762: |
| 3763: void OnTestProgramStart ( const UnitTest & unit_test ) override ; |
| 3764: void OnTestIterationStart ( const UnitTest & unit_test , int iteration ) override ; |
| 3765: void OnEnvironmentsSetUpStart ( const UnitTest & unit_test ) override ; |
| 3766: void OnEnvironmentsSetUpEnd ( const UnitTest & unit_test ) override ; |
| 3767: |
| 3768: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3769: void OnTestCaseStart ( const TestSuite & parameter ) override ; |
| 3770: # endif |
| 3771: void OnTestSuiteStart ( const TestSuite & parameter ) override ; |
| 3772: void OnTestStart ( const TestInfo & test_info ) override ; |
| 3773: void OnTestPartResult ( const TestPartResult & result ) override ; |
| 3774: void OnTestEnd ( const TestInfo & test_info ) override ; |
| 3775: |
| 3776: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3777: void OnTestCaseEnd ( const TestCase & parameter ) override ; |
| 3778: # endif |
| 3779: void OnTestSuiteEnd ( const TestSuite & parameter ) override ; |
| 3780: void OnEnvironmentsTearDownStart ( const UnitTest & unit_test ) override ; |
| 3781: void OnEnvironmentsTearDownEnd ( const UnitTest & unit_test ) override ; |
| 3782: void OnTestIterationEnd ( const UnitTest & unit_test , int iteration ) override ; |
| 3783: void OnTestProgramEnd ( const UnitTest & unit_test ) override ; |
| 3784: |
| 3785: private : |
| 3786: |
| 3787: |
| 3788: bool forwarding_enabled_ ; |
| 3789: |
| 3790: std :: vector < TestEventListener * > listeners_ ; |
| 3791: |
| 3792: GTEST_DISALLOW_COPY_AND_ASSIGN_ ( TestEventRepeater ) ; |
| 3793: } ; |
| 3794: |
| 3795: TestEventRepeater :: ~ TestEventRepeater ( ) {/*
ForEach(listeners_, Delete<TestEventListener>);
*/ |
| 3796: ForEach ( listeners_ , Delete < TestEventListener > ) ; |
| 3797: } |
| 3798: |
| 3799: void TestEventRepeater :: Append ( TestEventListener * listener ) {/*
listeners_.push_back(listener);
*/ |
3800: listeners_/* listeners_.push_back(listener) */ . push_back ( listener ) ; |
| 3801: } |
| 3802: |
| 3803: TestEventListener * TestEventRepeater :: Release ( TestEventListener * listener ) { |
| 3804: for ( size_t i = 0 ; i < listeners_ . size ( ) ; ++ i ) { |
| 3805: if listeners_ [ i ] == listener ) { |
| 3806: listeners_ . erase ( listeners_ . begin ( ) + static_cast < int > ( i ) ) ; |
| 3807: return listener ; |
| 3808: } |
| 3809: } |
| 3810: |
| 3811: return nullptr ; |
| 3812: } |
| 3813: |
| 3814: |
| 3815: |
| 3816: # define GTEST_REPEATER_METHOD_ ( Name , Type ) void |
| 3817: TestEventRepeater :: Name ( const Type & parameter ) { |
| 3818: if ( forwarding_enabled_ ) { |
| 3819: for ( size_t i = 0 ; i < listeners_ . size ( ) ; i ++ ) { |
| 3820: listeners_ [ i ] -> Name ( parameter ) ; |
| 3821: } |
| 3822: } \ |
| 3823: } |
| 3824: |
| 3825: |
| 3826: # define GTEST_REVERSE_REPEATER_METHOD_ ( Name , Type ) |
| 3827: void TestEventRepeater :: Name ( const Type & parameter ) { |
| 3828: if ( forwarding_enabled_ ) { |
| 3829: for ( size_t i = listeners_ . size ( ) ; i != 0 ; i -- ) { |
| 3830: listeners_ [ i - 1 ] -> Name ( parameter ) ; |
| 3831: } |
| 3832: } |
| 3833: } |
| 3834: |
| 3835: GTEST_REPEATER_METHOD_ ( OnTestProgramStart , UnitTest ) |
| 3836: GTEST_REPEATER_METHOD_ ( OnEnvironmentsSetUpStart , UnitTest ) |
| 3837: |
| 3838: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3839: GTEST_REPEATER_METHOD_ ( OnTestCaseStart , TestSuite ) |
| 3840: # endif |
| 3841: GTEST_REPEATER_METHOD_ ( OnTestSuiteStart , TestSuite ) |
| 3842: GTEST_REPEATER_METHOD_ ( OnTestStart , TestInfo ) |
| 3843: GTEST_REPEATER_METHOD_ ( OnTestPartResult , TestPartResult ) |
| 3844: GTEST_REPEATER_METHOD_ ( OnEnvironmentsTearDownStart , UnitTest ) |
| 3845: GTEST_REVERSE_REPEATER_METHOD_ ( OnEnvironmentsSetUpEnd , UnitTest ) |
| 3846: GTEST_REVERSE_REPEATER_METHOD_ ( OnEnvironmentsTearDownEnd , UnitTest ) |
| 3847: GTEST_REVERSE_REPEATER_METHOD_ ( OnTestEnd , TestInfo ) |
| 3848: |
| 3849: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 3850: GTEST_REVERSE_REPEATER_METHOD_ ( OnTestCaseEnd , TestSuite ) |
| 3851: # endif |
| 3852: GTEST_REVERSE_REPEATER_METHOD_ ( OnTestSuiteEnd , TestSuite ) |
| 3853: GTEST_REVERSE_REPEATER_METHOD_ ( OnTestProgramEnd , UnitTest ) |
| 3854: |
| 3855: # undef GTEST_REPEATER_METHOD_ |
| 3856: # undef GTEST_REVERSE_REPEATER_METHOD_ |
| 3857: |
| 3858: void TestEventRepeater :: OnTestIterationStart ( const UnitTest & unit_test , |
| 3859: int iteration ) {/*
if (forwarding_enabled_) {
for (size_t i = 0; i < listeners_.size(); i++) {
listeners_[i]->OnTestIterationStart(unit_test, iteration);
}
}
*/ |
3860: if/* if (forwarding_enabled_) {
for (size_t i = 0; i < listeners_.size(); i++) {
listeners_[i]->OnTestIterationStart(unit_test, iteration);
}
} */ forwarding_enabled_ ) {/*
for (size_t i = 0; i < listeners_.size(); i++) {
listeners_[i]->OnTestIterationStart(unit_test, iteration);
}
*/ |
3861: for/* for (size_t i = 0; i < listeners_.size(); i++) {
listeners_[i]->OnTestIterationStart(unit_test, iteration);
} */ ( size_t i = 0 ; i < listeners_ . size ( ) ; i ++ ) {/*
listeners_[i]->OnTestIterationStart(unit_test, iteration);
*/ |
3862: listeners_/* listeners_[i]->OnTestIterationStart(unit_test, iteration) */ [ i ] -> OnTestIterationStart ( unit_test , iteration ) ; |
| 3863: } |
| 3864: } |
| 3865: } |
| 3866: |
| 3867: void TestEventRepeater :: OnTestIterationEnd ( const UnitTest & unit_test , |
| 3868: int iteration ) {/*
if (forwarding_enabled_) {
for (size_t i = listeners_.size(); i > 0; i--) {
listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
}
}
*/ |
3869: if/* if (forwarding_enabled_) {
for (size_t i = listeners_.size(); i > 0; i--) {
listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
}
} */ forwarding_enabled_ ) {/*
for (size_t i = listeners_.size(); i > 0; i--) {
listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
}
*/ |
3870: for/* for (size_t i = listeners_.size(); i > 0; i--) {
listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
} */ ( size_t i = listeners_ . size ( ) ; i > 0 ; i -- ) {/*
listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration);
*/ |
3871: listeners_/* listeners_[i - 1]->OnTestIterationEnd(unit_test, iteration) */ [ i - 1 ] -> OnTestIterationEnd ( unit_test , iteration ) ; |
| 3872: } |
| 3873: } |
| 3874: } |
| 3875: |
| 3876: |
| 3877: |
| 3878: |
| 3879: class XmlUnitTestResultPrinter : public EmptyTestEventListener { |
| 3880: public : |
| 3881: explicit XmlUnitTestResultPrinter ( const char * output_file ) ; |
| 3882: |
| 3883: void OnTestIterationEnd ( const UnitTest & unit_test , int iteration ) override ; |
| 3884: void ListTestsMatchingFilter ( const std :: vector < TestSuite * > & test_suites ) ; |
| 3885: |
| 3886: |
| 3887: static void PrintXmlTestsList ( std :: ostream * stream , |
| 3888: const std :: vector < TestSuite * > & test_suites ) ; |
| 3889: |
| 3890: private : |
| 3891: |
| 3892: |
| 3893: static bool IsNormalizableWhitespace ( char c ) { |
| 3894: return ctruefalsetruefalsetruefalsetruefalsetruefalse == 0x9 == 0xA == 0xD ; |
| 3895: } |
| 3896: |
| 3897: |
| 3898: static bool IsValidXmlCharacter ( char c ) { |
| 3899: return IsNormalizableWhitespacetruefalsetruefalse ( c ) >= 0x20 ; |
| 3900: } |
| 3901: |
| 3902: |
| 3903: |
| 3904: |
| 3905: |
| 3906: static std :: string EscapeXml ( const std :: string & str , bool is_attribute ) ; |
| 3907: |
| 3908: |
| 3909: static std :: string RemoveInvalidXmlCharacters ( const std :: string & str ) ; |
| 3910: |
| 3911: |
| 3912: static std :: string EscapeXmlAttribute ( const std :: string & str ) { |
| 3913: return EscapeXml ( str , true ) ; |
| 3914: } |
| 3915: |
| 3916: |
| 3917: static std :: string EscapeXmlText ( const char * str ) { |
| 3918: return EscapeXml ( str , false ) ; |
| 3919: } |
| 3920: |
| 3921: |
| 3922: |
| 3923: static void OutputXmlAttribute ( std :: ostream * stream , |
| 3924: const std :: string & element_name , |
| 3925: const std :: string & name , |
| 3926: const std :: string & value ) ; |
| 3927: |
| 3928: |
| 3929: static void OutputXmlCDataSection ( :: std :: ostream * stream , const char * data ) ; |
| 3930: |
| 3931: |
| 3932: |
| 3933: |
| 3934: static void OutputXmlTestSuiteForTestResult ( :: std :: ostream * stream , |
| 3935: const TestResult & result ) ; |
| 3936: |
| 3937: |
| 3938: static void OutputXmlTestResult ( :: std :: ostream * stream , |
| 3939: const TestResult & result ) ; |
| 3940: |
| 3941: |
| 3942: static void OutputXmlTestInfo ( :: std :: ostream * stream , |
| 3943: const char * test_suite_name , |
| 3944: const TestInfo & test_info ) ; |
| 3945: |
| 3946: |
| 3947: static void PrintXmlTestSuite ( :: std :: ostream * stream , |
| 3948: const TestSuite & test_suite ) ; |
| 3949: |
| 3950: |
| 3951: static void PrintXmlUnitTest ( :: std :: ostream * stream , |
| 3952: const UnitTest & unit_test ) ; |
| 3953: |
| 3954: |
| 3955: |
| 3956: |
| 3957: |
| 3958: static std :: string TestPropertiesAsXmlAttributes ( const TestResult & result ) ; |
| 3959: |
| 3960: |
| 3961: |
| 3962: static void OutputXmlTestProperties ( std :: ostream * stream , |
| 3963: const TestResult & result ) ; |
| 3964: |
| 3965: |
| 3966: const std :: string output_file_ ; |
| 3967: |
| 3968: GTEST_DISALLOW_COPY_AND_ASSIGN_ ( XmlUnitTestResultPrinter ) ; |
| 3969: } ; |
| 3970: |
| 3971: |
| 3972: XmlUnitTestResultPrinter :: XmlUnitTestResultPrinter ( const char * output_file ) |
| 3973: : output_file_ ( output_file ) {/*
if (output_file_.empty()) {
GTEST_LOG_(FATAL) << "XML output file may not be null";
}
*/ |
3974: if/* if (output_file_.empty()) {
GTEST_LOG_(FATAL) << "XML output file may not be null";
} */ output_file_ . empty ( ) ) {/*
GTEST_LOG_(FATAL) << "XML output file may not be null";
*/ |
| 3975: GTEST_LOG_ ( FATAL ) << "XML output file may not be null" ; |
| 3976: } |
| 3977: } |
| 3978: |
| 3979: |
| 3980: void XmlUnitTestResultPrinter :: OnTestIterationEnd ( const UnitTest & unit_test , |
| 3981: int ) {/*
FILE* xmlout = OpenFileForWriting(output_file_);
std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test);
fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
fclose(xmlout);
*/ |
| 3982: FILE * xmlout = OpenFileForWriting ( output_file_ ) ; |
| 3983: std :: stringstream stream ; |
3984: PrintXmlUnitTest/* PrintXmlUnitTest(&stream, unit_test) */ ( & stream , unit_test ) ; |
| 3985: fprintf ( xmlout , "%s" , StringStreamToString ( & stream ) . c_str ( ) ) ; |
3986: fclose/* fclose(xmlout) */ ( xmlout ) ; |
| 3987: } |
| 3988: |
| 3989: void XmlUnitTestResultPrinter :: ListTestsMatchingFilter ( |
| 3990: const std :: vector < TestSuite * > & test_suites ) {/*
FILE* xmlout = OpenFileForWriting(output_file_);
std::stringstream stream;
PrintXmlTestsList(&stream, test_suites);
fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
fclose(xmlout);
*/ |
| 3991: FILE * xmlout = OpenFileForWriting ( output_file_ ) ; |
| 3992: std :: stringstream stream ; |
3993: PrintXmlTestsList/* PrintXmlTestsList(&stream, test_suites) */ ( & stream , test_suites ) ; |
| 3994: fprintf ( xmlout , "%s" , StringStreamToString ( & stream ) . c_str ( ) ) ; |
3995: fclose/* fclose(xmlout) */ ( xmlout ) ; |
| 3996: } |
| 3997: |
| 3998: |
| 3999: |
| 4000: |
| 4001: |
| 4002: |
| 4003: |
| 4004: |
| 4005: |
| 4006: |
| 4007: |
| 4008: std :: string XmlUnitTestResultPrinter :: EscapeXml ( |
| 4009: const std :: string & str , bool is_attribute ) { |
| 4010: Message m ; |
| 4011: |
4012: for/* for (size_t i = 0; i < str.size(); ++i) {
const char ch = str[i];
switch (ch) {
case '<':
m << "<";
break;
case '>':
m << ">";
break;
case '&':
m << "&";
break;
case '\'':
if (is_attribute)
m << "'";
else
m << '\'';
break;
case '"':
if (is_attribute)
m << """;
else
m << '"';
break;
default:
if (IsValidXmlCharacter(ch)) {
if (is_attribute && IsNormalizableWhitespace(ch))
m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
<< ";";
else
m << ch;
}
break;
}
} */ ( size_t i = 0 ; i < str . size ( ) ; ++ i ) {/*
const char ch = str[i];
switch (ch) {
case '<':
m << "<";
break;
case '>':
m << ">";
break;
case '&':
m << "&";
break;
case '\'':
if (is_attribute)
m << "'";
else
m << '\'';
break;
case '"':
if (is_attribute)
m << """;
else
m << '"';
break;
default:
if (IsValidXmlCharacter(ch)) {
if (is_attribute && IsNormalizableWhitespace(ch))
m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
<< ";";
else
m << ch;
}
break;
}
*/ |
| 4013: const char ch = str [ i ] ; |
4014: switch/* switch (ch) {
case '<':
m << "<";
break;
case '>':
m << ">";
break;
case '&':
m << "&";
break;
case '\'':
if (is_attribute)
m << "'";
else
m << '\'';
break;
case '"':
if (is_attribute)
m << """;
else
m << '"';
break;
default:
if (IsValidXmlCharacter(ch)) {
if (is_attribute && IsNormalizableWhitespace(ch))
m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
<< ";";
else
m << ch;
}
break;
} */ ( ch ) { |
| 4015: case '<' : |
| 4016: << "<" ; |
| 4017: break ; |
| 4018: case '>' : |
| 4019: << ">" ; |
| 4020: break ; |
| 4021: case '&' : |
| 4022: << "&" ; |
| 4023: break ; |
| 4024: case '\'' : |
4025: if/* if (is_attribute)
m << "'";
else
m << '\'' */ is_attribute ) |
| 4026: m << "'" ; |
| 4027: else |
| 4028: m << '\'' ; |
| 4029: break ; |
| 4030: case '"' : |
4031: if/* if (is_attribute)
m << """;
else
m << '"' */ is_attribute ) |
| 4032: m << """ ; |
| 4033: else |
| 4034: m << '"' ; |
| 4035: break ; |
| 4036: default : |
4037: if/* if (IsValidXmlCharacter(ch)) {
if (is_attribute && IsNormalizableWhitespace(ch))
m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
<< ";";
else
m << ch;
} */ IsValidXmlCharacter ( ch ) ) {/*
if (is_attribute && IsNormalizableWhitespace(ch))
m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
<< ";";
else
m << ch;
*/ |
4038: if/* if (is_attribute && IsNormalizableWhitespace(ch))
m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
<< ";";
else
m << ch */ is_attribute IsNormalizableWhitespace ( ch ) ) |
| 4039: m << "&#x" << String :: FormatByte ( static_cast < unsigned char > ( ch ) ) |
| 4040: << ";" ; |
| 4041: else |
| 4042: m << ch ; |
| 4043: } |
| 4044: break ; |
| 4045: } |
| 4046: } |
| 4047: |
| 4048: return m . GetString ( ) ; |
| 4049: } |
| 4050: |
| 4051: |
| 4052: |
| 4053: |
| 4054: std :: string XmlUnitTestResultPrinter :: RemoveInvalidXmlCharacters ( |
| 4055: const std :: string & str ) { |
| 4056: std :: string output ; |
4057: output/* output.reserve(str.size()) */ . reserve ( str . size ( ) ) ; |
| 4058: for ( std :: string :: const_iterator it = str . begin ( ) ; it != str . end ( ) ; ++ it ) |
| 4059: if ( IsValidXmlCharacter ( * it ) ) |
| 4060: output . push_back ( * it ) ; |
| 4061: |
| 4062: return output ; |
| 4063: } |
| 4064: |
| 4065: |
| 4066: |
| 4067: |
| 4068: |
| 4069: |
| 4070: |
| 4071: |
| 4072: |
| 4073: |
| 4074: |
| 4075: |
| 4076: |
| 4077: |
| 4078: |
| 4079: |
| 4080: |
| 4081: |
| 4082: |
| 4083: std :: string FormatTimeInMillisAsSeconds ( TimeInMillis ms ) { |
| 4084: :: std :: stringstream ss ; |
4085: ss/* ss << (static_cast<double>(ms) * 1e-3) */ << ( static_cast < double > ( ms ) * 1e-3 ) ; |
| 4086: return ss . str ( ) ; |
| 4087: } |
| 4088: |
| 4089: static bool PortableLocaltime ( time_t seconds , struct tm * out ) { |
| 4090: # if defined ( _MSC_VER ) |
| 4091: return localtime_s ( out , & seconds ) == 0 ; |
| 4092: # elif defined ( __MINGW32__ ) || defined ( __MINGW64__ ) |
| 4093: |
| 4094: |
| 4095: struct tm * tm_ptr = localtime ( & seconds ) ; |
| 4096: if ( tm_ptr == nullptr ) return false ; |
| 4097: * out = * tm_ptr ; |
| 4098: return true ; |
| 4099: # elif defined ( __STDC_LIB_EXT1__ ) |
| 4100: |
| 4101: |
| 4102: return localtime_s ( & seconds , out ) != nullptr ; |
| 4103: # else |
| 4104: return ( & seconds , out ) != nullptr ; |
| 4105: # endif |
| 4106: } |
| 4107: |
| 4108: |
| 4109: |
| 4110: std :: string FormatEpochTimeInMillisAsIso8601 ( TimeInMillis ms ) { |
| 4111: struct tm time_struct ; |
| 4112: if (truefalse!!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct) ! PortableLocaltime ( static_cast < time_t > ( ms / 1000 ) , & time_struct ) ) |
| 4113: return "" ; |
| 4114: |
| 4115: return StreamableToString ( time_struct . tm_year + 1900 ) + "-" + |
| 4116: String :: FormatIntWidth2 ( time_struct . tm_mon + 1 ) + "-" + |
| 4117: String :: FormatIntWidth2 ( time_struct . tm_mday ) + "T" + |
| 4118: String :: FormatIntWidth2 ( time_struct . tm_hour ) + ":" + |
| 4119: String :: FormatIntWidth2 ( time_struct . tm_min ) + ":" + |
| 4120: String :: FormatIntWidth2 ( time_struct . tm_sec ) + "." + |
| 4121: String :: FormatIntWidthN ( static_cast < int > ( ms % 1000 ) , 3 ) ; |
| 4122: } |
| 4123: |
| 4124: |
| 4125: void XmlUnitTestResultPrinter :: OutputXmlCDataSection ( :: std :: ostream * stream , |
| 4126: const char * data ) {/*
const char* segment = data;
*stream << "<![CDATA[";
for (;;) {
const char* const next_segment = strstr(segment, "]]>");
if (next_segment != nullptr) {
stream->write(
segment, static_cast<std::streamsize>(next_segment - segment));
*stream << "]]>]]><![CDATA[";
segment = next_segment + strlen("]]>");
} else {
*stream << segment;
break;
}
}
*stream << "]]>";
*/ |
| 4127: const char * segment = data ; |
4128: */* *stream << "<![CDATA[" */ stream << "<![CDATA[" ; |
4129: for/* for (;;) {
const char* const next_segment = strstr(segment, "]]>");
if (next_segment != nullptr) {
stream->write(
segment, static_cast<std::streamsize>(next_segment - segment));
*stream << "]]>]]><![CDATA[";
segment = next_segment + strlen("]]>");
} else {
*stream << segment;
break;
}
} */ ( ; ; ) {/*
const char* const next_segment = strstr(segment, "]]>");
if (next_segment != nullptr) {
stream->write(
segment, static_cast<std::streamsize>(next_segment - segment));
*stream << "]]>]]><![CDATA[";
segment = next_segment + strlen("]]>");
} else {
*stream << segment;
break;
}
*/ |
| 4130: const char * const next_segment = strstr ( segment , "]]>" ) ; |
4131: if/* if (next_segment != nullptr) {
stream->write(
segment, static_cast<std::streamsize>(next_segment - segment));
*stream << "]]>]]><![CDATA[";
segment = next_segment + strlen("]]>");
} else {
*stream << segment;
break;
} */ next_segment != nullptr ) {/*
stream->write(
segment, static_cast<std::streamsize>(next_segment - segment));
*stream << "]]>]]><![CDATA[";
segment = next_segment + strlen("]]>");
*/ |
4132: stream/* stream->write(
segment, static_cast<std::streamsize>(next_segment - segment)) */ -> write ( |
| 4133: segment , static_cast < std :: streamsize > ( next_segment - segment ) ) ; |
4134: */* *stream << "]]>]]><![CDATA[" */ stream << "]]>]]><![CDATA[" ; |
4135: segment/* segment = next_segment + strlen("]]>") */ = next_segment + strlen ( "]]>" ) ; |
| 4136: } else {/*
*stream << segment;
break;
*/ |
4137: */* *stream << segment */ stream << segment ; |
| 4138: break ; |
| 4139: } |
| 4140: } |
| 4141: stream << "]]>" ; |
| 4142: } |
| 4143: |
| 4144: void XmlUnitTestResultPrinter :: OutputXmlAttribute ( |
| 4145: std :: ostream * stream , |
| 4146: const std :: string & element_name , |
| 4147: const std :: string & name , |
| 4148: const std :: string & value ) {/*
const std::vector<std::string>& allowed_names =
GetReservedOutputAttributesForElement(element_name);
GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
allowed_names.end())
<< "Attribute " << name << " is not allowed for element <" << element_name
<< ">.";
*stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\"";
*/ |
| 4149: const std :: vector < std :: string > & allowed_names = |
| 4150: GetReservedOutputAttributesForElement ( element_name ) ; |
| 4151: |
| 4152: GTEST_CHECK_ ( std :: find ( allowed_names . begin ( ) , allowed_names . end ( ) , name ) != |
| 4153: allowed_names . end ( ) ) |
| 4154: << "Attribute " << name << " is not allowed for element <" << element_name |
| 4155: << ">." ; |
| 4156: |
| 4157: * stream << " " << name << "=\"" << EscapeXmlAttribute ( value ) << "\"" ; |
| 4158: } |
| 4159: |
| 4160: |
| 4161: void XmlUnitTestResultPrinter :: OutputXmlTestSuiteForTestResult ( |
| 4162: :: std :: ostream * stream , const TestResult & result ) {/*
// Output the boilerplate for a minimal test suite with one test.
*stream << " <testsuite";
OutputXmlAttribute(stream, "testsuite", "name", "NonTestSuiteFailure");
OutputXmlAttribute(stream, "testsuite", "tests", "1");
OutputXmlAttribute(stream, "testsuite", "failures", "1");
OutputXmlAttribute(stream, "testsuite", "disabled", "0");
OutputXmlAttribute(stream, "testsuite", "skipped", "0");
OutputXmlAttribute(stream, "testsuite", "errors", "0");
OutputXmlAttribute(stream, "testsuite", "time",
FormatTimeInMillisAsSeconds(result.elapsed_time()));
OutputXmlAttribute(
stream, "testsuite", "timestamp",
FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));
*stream << ">";
// Output the boilerplate for a minimal test case with a single test.
*stream << " <testcase";
OutputXmlAttribute(stream, "testcase", "name", "");
OutputXmlAttribute(stream, "testcase", "status", "run");
OutputXmlAttribute(stream, "testcase", "result", "completed");
OutputXmlAttribute(stream, "testcase", "classname", "");
OutputXmlAttribute(stream, "testcase", "time",
FormatTimeInMillisAsSeconds(result.elapsed_time()));
OutputXmlAttribute(
stream, "testcase", "timestamp",
FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));
// Output the actual test result.
OutputXmlTestResult(stream, result);
// Complete the test suite.
*stream << " </testsuite>\n";
*/ |
| 4163: |
4164: */* *stream << " <testsuite" */ stream << " <testsuite" ; |
| 4165: OutputXmlAttribute ( stream , "testsuite" , "name" , "NonTestSuiteFailure" ) ; |
| 4166: OutputXmlAttribute ( stream , "testsuite" , "tests" , "1" ) ; |
| 4167: OutputXmlAttribute ( stream , "testsuite" , "failures" , "1" ) ; |
| 4168: OutputXmlAttribute ( stream , "testsuite" , "disabled" , "0" ) ; |
| 4169: OutputXmlAttribute ( stream , "testsuite" , "skipped" , "0" ) ; |
| 4170: OutputXmlAttribute ( stream , "testsuite" , "errors" , "0" ) ; |
| 4171: OutputXmlAttribute ( stream , "testsuite" , "time" , |
| 4172: FormatTimeInMillisAsSeconds ( result . elapsed_time ( ) ) ) ; |
| 4173: OutputXmlAttribute ( |
| 4174: stream , "testsuite" , "timestamp" , |
| 4175: FormatEpochTimeInMillisAsIso8601 ( result . start_timestamp ( ) ) ) ; |
| 4176: stream << ">" ; |
| 4177: |
| 4178: |
4179: */* *stream << " <testcase" */ stream << " <testcase" ; |
| 4180: OutputXmlAttribute ( stream , "testcase" , "name" , "" ) ; |
| 4181: OutputXmlAttribute ( stream , "testcase" , "status" , "run" ) ; |
| 4182: OutputXmlAttribute ( stream , "testcase" , "result" , "completed" ) ; |
| 4183: OutputXmlAttribute ( stream , "testcase" , "classname" , "" ) ; |
| 4184: OutputXmlAttribute ( stream , "testcase" , "time" , |
| 4185: FormatTimeInMillisAsSeconds ( result . elapsed_time ( ) ) ) ; |
| 4186: OutputXmlAttribute ( |
| 4187: stream , "testcase" , "timestamp" , |
| 4188: FormatEpochTimeInMillisAsIso8601 ( result . start_timestamp ( ) ) ) ; |
| 4189: |
| 4190: |
4191: OutputXmlTestResult/* OutputXmlTestResult(stream, result) */ ( stream , result ) ; |
| 4192: |
| 4193: |
4194: */* *stream << " </testsuite>\n" */ stream << " </testsuite>\n" ; |
| 4195: } |
| 4196: |
| 4197: |
| 4198: void XmlUnitTestResultPrinter :: OutputXmlTestInfo ( :: std :: ostream * stream , |
| 4199: const char * test_suite_name , |
| 4200: const TestInfo & test_info ) {/*
const TestResult& result = *test_info.result();
const std::string kTestsuite = "testcase";
if (test_info.is_in_another_shard()) {
return;
}
*stream << " <testcase";
OutputXmlAttribute(stream, kTestsuite, "name", test_info.name());
if (test_info.value_param() != nullptr) {
OutputXmlAttribute(stream, kTestsuite, "value_param",
test_info.value_param());
}
if (test_info.type_param() != nullptr) {
OutputXmlAttribute(stream, kTestsuite, "type_param",
test_info.type_param());
}
if (GTEST_FLAG(list_tests)) {
OutputXmlAttribute(stream, kTestsuite, "file", test_info.file());
OutputXmlAttribute(stream, kTestsuite, "line",
StreamableToString(test_info.line()));
*stream << " />\n";
return;
}
OutputXmlAttribute(stream, kTestsuite, "status",
test_info.should_run() ? "run" : "notrun");
OutputXmlAttribute(stream, kTestsuite, "result",
test_info.should_run()
? (result.Skipped() ? "skipped" : "completed")
: "suppressed");
OutputXmlAttribute(stream, kTestsuite, "time",
FormatTimeInMillisAsSeconds(result.elapsed_time()));
OutputXmlAttribute(
stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsIso8601(result.start_timestamp()));
OutputXmlAttribute(stream, kTestsuite, "classname", test_suite_name);
OutputXmlTestResult(stream, result);
*/ |
| 4201: const TestResult & result = * test_info . result ( ) ; |
| 4202: const std :: string kTestsuite = "testcase" ; |
| 4203: |
4204: if/* if (test_info.is_in_another_shard()) {
return;
} */ test_info . is_in_another_shard ( ) ) |
| 4205: ; |
| 4206: } |
| 4207: |
4208: */* *stream << " <testcase" */ stream << " <testcase" ; |
| 4209: OutputXmlAttribute ( stream , kTestsuite , "name" , test_info . name ( ) ) ; |
| 4210: |
4211: if/* if (test_info.value_param() != nullptr) {
OutputXmlAttribute(stream, kTestsuite, "value_param",
test_info.value_param());
} */ test_info . value_param ( ) != nullptr ) {/*
OutputXmlAttribute(stream, kTestsuite, "value_param",
test_info.value_param());
*/ |
| 4212: OutputXmlAttribute ( stream , kTestsuite , "value_param" , |
| 4213: test_info . value_param ( ) ) ; |
| 4214: } |
4215: if/* if (test_info.type_param() != nullptr) {
OutputXmlAttribute(stream, kTestsuite, "type_param",
test_info.type_param());
} */ test_info . type_param ( ) != nullptr ) {/*
OutputXmlAttribute(stream, kTestsuite, "type_param",
test_info.type_param());
*/ |
| 4216: OutputXmlAttribute ( stream , kTestsuite , "type_param" , |
| 4217: test_info . type_param ( ) ) ; |
| 4218: } |
4219: if/* if (GTEST_FLAG(list_tests)) {
OutputXmlAttribute(stream, kTestsuite, "file", test_info.file());
OutputXmlAttribute(stream, kTestsuite, "line",
StreamableToString(test_info.line()));
*stream << " />\n";
return;
} */ ( GTEST_FLAG ( list_tests ) ) {/*
OutputXmlAttribute(stream, kTestsuite, "file", test_info.file());
OutputXmlAttribute(stream, kTestsuite, "line",
StreamableToString(test_info.line()));
*stream << " />\n";
return;
*/ |
| 4220: OutputXmlAttribute ( stream , kTestsuite , "file" , test_info . file ( ) ) ; |
| 4221: OutputXmlAttribute ( stream , kTestsuite , "line" , |
| 4222: StreamableToString ( test_info . line ( ) ) ) ; |
4223: */* *stream << " />\n" */ stream << " />\n" ; |
| 4224: ; |
| 4225: } |
| 4226: |
| 4227: OutputXmlAttribute ( stream , kTestsuite , "status" , |
| 4228: test_info . should_run ( ) ? "run" : "notrun" ) ; |
| 4229: OutputXmlAttribute ( stream , kTestsuite , "result" , |
| 4230: test_info . should_run ( ) |
| 4231: ? ( result . Skipped ( ) ? "skipped" : "completed" ) |
| 4232: : "suppressed" ) ; |
| 4233: OutputXmlAttribute ( stream , kTestsuite , "time" , |
| 4234: FormatTimeInMillisAsSeconds ( result . elapsed_time ( ) ) ) ; |
| 4235: OutputXmlAttribute ( |
| 4236: stream , kTestsuite , "timestamp" , |
| 4237: FormatEpochTimeInMillisAsIso8601 ( result . start_timestamp ( ) ) ) ; |
| 4238: OutputXmlAttribute ( stream , kTestsuite , "classname" , test_suite_name ) ; |
| 4239: |
4240: OutputXmlTestResult/* OutputXmlTestResult(stream, result) */ ( stream , result ) ; |
| 4241: } |
| 4242: |
| 4243: void XmlUnitTestResultPrinter :: OutputXmlTestResult ( :: std :: ostream * stream , |
| 4244: const TestResult & result ) {/*
int failures = 0;
int skips = 0;
for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
if (part.failed()) {
if (++failures == 1 && skips == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <failure message=\""
<< EscapeXmlAttribute(summary)
<< "\" type=\"\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</failure>\n";
} else if (part.skipped()) {
if (++skips == 1 && failures == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <skipped message=\""
<< EscapeXmlAttribute(summary.c_str()) << "\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</skipped>\n";
}
}
if (failures == 0 && skips == 0 && result.test_property_count() == 0) {
*stream << " />\n";
} else {
if (failures == 0 && skips == 0) {
*stream << ">\n";
}
OutputXmlTestProperties(stream, result);
*stream << " </testcase>\n";
}
*/ |
| 4245: int failures = 0 ; |
| 4246: int skips = 0 ; |
4247: for/* for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
if (part.failed()) {
if (++failures == 1 && skips == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <failure message=\""
<< EscapeXmlAttribute(summary)
<< "\" type=\"\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</failure>\n";
} else if (part.skipped()) {
if (++skips == 1 && failures == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <skipped message=\""
<< EscapeXmlAttribute(summary.c_str()) << "\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</skipped>\n";
}
} */ ( int i = 0 ; i < result . total_part_count ( ) ; ++ i ) {/*
const TestPartResult& part = result.GetTestPartResult(i);
if (part.failed()) {
if (++failures == 1 && skips == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <failure message=\""
<< EscapeXmlAttribute(summary)
<< "\" type=\"\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</failure>\n";
} else if (part.skipped()) {
if (++skips == 1 && failures == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <skipped message=\""
<< EscapeXmlAttribute(summary.c_str()) << "\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</skipped>\n";
}
*/ |
| 4248: const TestPartResult & part = result . GetTestPartResult ( i ) ; |
4249: if/* if (part.failed()) {
if (++failures == 1 && skips == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <failure message=\""
<< EscapeXmlAttribute(summary)
<< "\" type=\"\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</failure>\n";
} else if (part.skipped()) {
if (++skips == 1 && failures == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <skipped message=\""
<< EscapeXmlAttribute(summary.c_str()) << "\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</skipped>\n";
} */ part . failed ( ) ) {/*
if (++failures == 1 && skips == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <failure message=\""
<< EscapeXmlAttribute(summary)
<< "\" type=\"\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</failure>\n";
*/ |
4250: if/* if (++failures == 1 && skips == 0) {
*stream << ">\n";
} */ (truefalsetruefalsetruefalse ++ failures == 1 == 0 ) |
| 4251: stream << ">\n" ; |
| 4252: } |
| 4253: const std :: string location = |
| 4254: internal :: FormatCompilerIndependentFileLocation ( part . file_name ( ) , |
| 4255: part . line_number ( ) ) ; |
| 4256: const std :: string summary = location + "\n" + part . summary ( ) ; |
| 4257: * stream << " <failure message=\"" |
| 4258: << EscapeXmlAttribute ( summary ) |
| 4259: << "\" type=\"\">" ; |
| 4260: const std :: string detail = location + "\n" + part . message ( ) ; |
| 4261: OutputXmlCDataSection ( stream , RemoveInvalidXmlCharacters ( detail ) . c_str ( ) ) ; |
4262: */* *stream << "</failure>\n" */ stream << "</failure>\n" ; |
| 4263: } else if/* if (part.skipped()) {
if (++skips == 1 && failures == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <skipped message=\""
<< EscapeXmlAttribute(summary.c_str()) << "\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</skipped>\n";
} */ part . skipped ( ) ) {/*
if (++skips == 1 && failures == 0) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <skipped message=\""
<< EscapeXmlAttribute(summary.c_str()) << "\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</skipped>\n";
*/ |
4264: if/* if (++skips == 1 && failures == 0) {
*stream << ">\n";
} */ (truefalsetruefalsetruefalse ++ skips == 1 == 0 ) |
| 4265: stream << ">\n" ; |
| 4266: } |
| 4267: const std :: string location = |
| 4268: internal :: FormatCompilerIndependentFileLocation ( part . file_name ( ) , |
| 4269: part . line_number ( ) ) ; |
| 4270: const std :: string summary = location + "\n" + part . summary ( ) ; |
| 4271: * stream << " <skipped message=\"" |
| 4272: << EscapeXmlAttribute ( summary . c_str ( ) ) << "\">" ; |
| 4273: const std :: string detail = location + "\n" + part . message ( ) ; |
| 4274: OutputXmlCDataSection ( stream , RemoveInvalidXmlCharacters ( detail ) . c_str ( ) ) ; |
4275: */* *stream << "</skipped>\n" */ stream << "</skipped>\n" ; |
| 4276: } |
| 4277: } |
| 4278: |
4279: if/* if (failures == 0 && skips == 0 && result.test_property_count() == 0) {
*stream << " />\n";
} else {
if (failures == 0 && skips == 0) {
*stream << ">\n";
}
OutputXmlTestProperties(stream, result);
*stream << " </testcase>\n";
} */ (truefalsetruefalsetruefalsetruefalsetruefalse failures == 0 == 0 . test_property_count ( ) == 0 ) {/*
*stream << " />\n";
*/ |
4280: */* *stream << " />\n" */ stream << " />\n" ; |
| 4281: } else {/*
if (failures == 0 && skips == 0) {
*stream << ">\n";
}
OutputXmlTestProperties(stream, result);
*stream << " </testcase>\n";
*/ |
4282: if/* if (failures == 0 && skips == 0) {
*stream << ">\n";
} */ (truefalsetruefalsetruefalse failures == 0 == 0 ) |
| 4283: stream << ">\n" ; |
| 4284: } |
4285: OutputXmlTestProperties/* OutputXmlTestProperties(stream, result) */ ( stream , result ) ; |
4286: */* *stream << " </testcase>\n" */ stream << " </testcase>\n" ; |
| 4287: } |
| 4288: } |
| 4289: |
| 4290: |
| 4291: void XmlUnitTestResultPrinter :: PrintXmlTestSuite ( std :: ostream * stream , |
| 4292: const TestSuite & test_suite ) {/*
const std::string kTestsuite = "testsuite";
*stream << " <" << kTestsuite;
OutputXmlAttribute(stream, kTestsuite, "name", test_suite.name());
OutputXmlAttribute(stream, kTestsuite, "tests",
StreamableToString(test_suite.reportable_test_count()));
if (!GTEST_FLAG(list_tests)) {
OutputXmlAttribute(stream, kTestsuite, "failures",
StreamableToString(test_suite.failed_test_count()));
OutputXmlAttribute(
stream, kTestsuite, "disabled",
StreamableToString(test_suite.reportable_disabled_test_count()));
OutputXmlAttribute(stream, kTestsuite, "skipped",
StreamableToString(test_suite.skipped_test_count()));
OutputXmlAttribute(stream, kTestsuite, "errors", "0");
OutputXmlAttribute(stream, kTestsuite, "time",
FormatTimeInMillisAsSeconds(test_suite.elapsed_time()));
OutputXmlAttribute(
stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsIso8601(test_suite.start_timestamp()));
*stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result());
}
*stream << ">\n";
for (int i = 0; i < test_suite.total_test_count(); ++i) {
if (test_suite.GetTestInfo(i)->is_reportable())
OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
}
*stream << " </" << kTestsuite << ">\n";
*/ |
| 4293: const std :: string kTestsuite = "testsuite" ; |
4294: */* *stream << " <" << kTestsuite */ stream << " <" << kTestsuite ; |
| 4295: OutputXmlAttribute ( stream , kTestsuite , "name" , test_suite . name ( ) ) ; |
| 4296: OutputXmlAttribute ( stream , kTestsuite , "tests" , |
| 4297: StreamableToString ( test_suite . reportable_test_count ( ) ) ) ; |
4298: if/* if (!GTEST_FLAG(list_tests)) {
OutputXmlAttribute(stream, kTestsuite, "failures",
StreamableToString(test_suite.failed_test_count()));
OutputXmlAttribute(
stream, kTestsuite, "disabled",
StreamableToString(test_suite.reportable_disabled_test_count()));
OutputXmlAttribute(stream, kTestsuite, "skipped",
StreamableToString(test_suite.skipped_test_count()));
OutputXmlAttribute(stream, kTestsuite, "errors", "0");
OutputXmlAttribute(stream, kTestsuite, "time",
FormatTimeInMillisAsSeconds(test_suite.elapsed_time()));
OutputXmlAttribute(
stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsIso8601(test_suite.start_timestamp()));
*stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result());
} */ (truefalse!!GTEST_FLAG(list_tests) ! GTEST_FLAG ( list_tests ) ) {/*
OutputXmlAttribute(stream, kTestsuite, "failures",
StreamableToString(test_suite.failed_test_count()));
OutputXmlAttribute(
stream, kTestsuite, "disabled",
StreamableToString(test_suite.reportable_disabled_test_count()));
OutputXmlAttribute(stream, kTestsuite, "skipped",
StreamableToString(test_suite.skipped_test_count()));
OutputXmlAttribute(stream, kTestsuite, "errors", "0");
OutputXmlAttribute(stream, kTestsuite, "time",
FormatTimeInMillisAsSeconds(test_suite.elapsed_time()));
OutputXmlAttribute(
stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsIso8601(test_suite.start_timestamp()));
*stream << TestPropertiesAsXmlAttributes(test_suite.ad_hoc_test_result());
*/ |
| 4299: OutputXmlAttribute ( stream , kTestsuite , "failures" , |
| 4300: StreamableToString ( test_suite . failed_test_count ( ) ) ) ; |
| 4301: OutputXmlAttribute ( |
| 4302: stream , kTestsuite , "disabled" , |
| 4303: StreamableToString ( test_suite . reportable_disabled_test_count ( ) ) ) ; |
| 4304: OutputXmlAttribute ( stream , kTestsuite , "skipped" , |
| 4305: StreamableToString ( test_suite . skipped_test_count ( ) ) ) ; |
| 4306: |
| 4307: OutputXmlAttribute ( stream , kTestsuite , "errors" , "0" ) ; |
| 4308: |
| 4309: OutputXmlAttribute ( stream , kTestsuite , "time" , |
| 4310: FormatTimeInMillisAsSeconds ( test_suite . elapsed_time ( ) ) ) ; |
| 4311: OutputXmlAttribute ( |
| 4312: stream , kTestsuite , "timestamp" , |
| 4313: FormatEpochTimeInMillisAsIso8601 ( test_suite . start_timestamp ( ) ) ) ; |
| 4314: * stream << TestPropertiesAsXmlAttributes ( test_suite . ad_hoc_test_result ( ) ) ; |
| 4315: } |
| 4316: stream << ">\n" ; |
4317: for/* for (int i = 0; i < test_suite.total_test_count(); ++i) {
if (test_suite.GetTestInfo(i)->is_reportable())
OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
} */ ( int i = 0 ; i < test_suite . total_test_count ( ) ; ++ i ) {/*
if (test_suite.GetTestInfo(i)->is_reportable())
OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
*/ |
4318: if/* if (test_suite.GetTestInfo(i)->is_reportable())
OutputXmlTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i)) */ test_suite . GetTestInfo ( i ) -> is_reportable ( ) ) |
| 4319: OutputXmlTestInfo ( stream , test_suite . name ( ) , * test_suite . GetTestInfo ( i ) ) ; |
| 4320: } |
4321: */* *stream << " </" << kTestsuite << ">\n" */ stream << " </" << kTestsuite << ">\n" ; |
| 4322: } |
| 4323: |
| 4324: |
| 4325: void XmlUnitTestResultPrinter :: PrintXmlUnitTest ( std :: ostream * stream , |
| 4326: const UnitTest & unit_test ) {/*
const std::string kTestsuites = "testsuites";
*stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
*stream << "<" << kTestsuites;
OutputXmlAttribute(stream, kTestsuites, "tests",
StreamableToString(unit_test.reportable_test_count()));
OutputXmlAttribute(stream, kTestsuites, "failures",
StreamableToString(unit_test.failed_test_count()));
OutputXmlAttribute(
stream, kTestsuites, "disabled",
StreamableToString(unit_test.reportable_disabled_test_count()));
OutputXmlAttribute(stream, kTestsuites, "errors", "0");
OutputXmlAttribute(stream, kTestsuites, "time",
FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));
OutputXmlAttribute(
stream, kTestsuites, "timestamp",
FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));
if (GTEST_FLAG(shuffle)) {
OutputXmlAttribute(stream, kTestsuites, "random_seed",
StreamableToString(unit_test.random_seed()));
}
*stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
*stream << ">\n";
for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)
PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));
}
// If there was a test failure outside of one of the test suites (like in a
// test environment) include that in the output.
if (unit_test.ad_hoc_test_result().Failed()) {
OutputXmlTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
}
*stream << "</" << kTestsuites << ">\n";
*/ |
| 4327: const std :: string kTestsuites = "testsuites" ; |
| 4328: |
4329: */* *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" */ stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ; |
4330: */* *stream << "<" << kTestsuites */ stream << "<" << kTestsuites ; |
| 4331: |
| 4332: OutputXmlAttribute ( stream , kTestsuites , "tests" , |
| 4333: StreamableToString ( unit_test . reportable_test_count ( ) ) ) ; |
| 4334: OutputXmlAttribute ( stream , kTestsuites , "failures" , |
| 4335: StreamableToString ( unit_test . failed_test_count ( ) ) ) ; |
| 4336: OutputXmlAttribute ( |
| 4337: stream , kTestsuites , "disabled" , |
| 4338: StreamableToString ( unit_test . reportable_disabled_test_count ( ) ) ) ; |
| 4339: OutputXmlAttribute ( stream , kTestsuites , "errors" , "0" ) ; |
| 4340: OutputXmlAttribute ( stream , kTestsuites , "time" , |
| 4341: FormatTimeInMillisAsSeconds ( unit_test . elapsed_time ( ) ) ) ; |
| 4342: OutputXmlAttribute ( |
| 4343: stream , kTestsuites , "timestamp" , |
| 4344: FormatEpochTimeInMillisAsIso8601 ( unit_test . start_timestamp ( ) ) ) ; |
| 4345: |
4346: if/* if (GTEST_FLAG(shuffle)) {
OutputXmlAttribute(stream, kTestsuites, "random_seed",
StreamableToString(unit_test.random_seed()));
} */ ( GTEST_FLAG ( shuffle ) ) {/*
OutputXmlAttribute(stream, kTestsuites, "random_seed",
StreamableToString(unit_test.random_seed()));
*/ |
| 4347: OutputXmlAttribute ( stream , kTestsuites , "random_seed" , |
| 4348: StreamableToString ( unit_test . random_seed ( ) ) ) ; |
| 4349: } |
| 4350: * stream << TestPropertiesAsXmlAttributes ( unit_test . ad_hoc_test_result ( ) ) ; |
| 4351: |
| 4352: OutputXmlAttribute ( stream , kTestsuites , "name" , "AllTests" ) ; |
| 4353: stream << ">\n" ; |
| 4354: |
4355: for/* for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)
PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));
} */ ( int i = 0 ; i < unit_test . total_test_suite_count ( ) ; ++ i ) {/*
if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)
PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i));
*/ |
4356: if/* if (unit_test.GetTestSuite(i)->reportable_test_count() > 0)
PrintXmlTestSuite(stream, *unit_test.GetTestSuite(i)) */ unit_test . GetTestSuite ( i ) -> reportable_test_count ( ) > 0 ) |
| 4357: PrintXmlTestSuite ( stream , * unit_test . GetTestSuite ( i ) ) ; |
| 4358: } |
| 4359: |
| 4360: |
| 4361: |
4362: if/* if (unit_test.ad_hoc_test_result().Failed()) {
OutputXmlTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
} */ unit_test . ad_hoc_test_result ( ) . Failed ( ) ) {/*
OutputXmlTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
*/ |
4363: OutputXmlTestSuiteForTestResult/* OutputXmlTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result()) */ ( stream , unit_test . ad_hoc_test_result ( ) ) ; |
| 4364: } |
| 4365: |
4366: */* *stream << "</" << kTestsuites << ">\n" */ stream << "</" << kTestsuites << ">\n" ; |
| 4367: } |
| 4368: |
| 4369: void XmlUnitTestResultPrinter :: PrintXmlTestsList ( |
| 4370: std :: ostream * stream , const std :: vector < TestSuite * > & test_suites ) {/*
const std::string kTestsuites = "testsuites";
*stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
*stream << "<" << kTestsuites;
int total_tests = 0;
for (auto test_suite : test_suites) {
total_tests += test_suite->total_test_count();
}
OutputXmlAttribute(stream, kTestsuites, "tests",
StreamableToString(total_tests));
OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
*stream << ">\n";
for (auto test_suite : test_suites) {
PrintXmlTestSuite(stream, *test_suite);
}
*stream << "</" << kTestsuites << ">\n";
*/ |
| 4371: const std :: string kTestsuites = "testsuites" ; |
| 4372: |
4373: */* *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" */ stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ; |
4374: */* *stream << "<" << kTestsuites */ stream << "<" << kTestsuites ; |
| 4375: |
| 4376: int total_tests = 0 ; |
4377: for/* for (auto test_suite : test_suites) {
total_tests += test_suite->total_test_count();
} */ ( auto test_suite : test_suites ) {/*
total_tests += test_suite->total_test_count();
*/ |
4378: total_tests/* total_tests += test_suite->total_test_count() */ += test_suite -> total_test_count ( ) ; |
| 4379: } |
| 4380: OutputXmlAttribute ( stream , kTestsuites , "tests" , |
| 4381: StreamableToString ( total_tests ) ) ; |
| 4382: OutputXmlAttribute ( stream , kTestsuites , "name" , "AllTests" ) ; |
| 4383: stream << ">\n" ; |
| 4384: |
4385: for/* for (auto test_suite : test_suites) {
PrintXmlTestSuite(stream, *test_suite);
} */ ( auto test_suite : test_suites ) {/*
PrintXmlTestSuite(stream, *test_suite);
*/ |
4386: PrintXmlTestSuite/* PrintXmlTestSuite(stream, *test_suite) */ ( stream , * test_suite ) ; |
| 4387: } |
4388: */* *stream << "</" << kTestsuites << ">\n" */ stream << "</" << kTestsuites << ">\n" ; |
| 4389: } |
| 4390: |
| 4391: |
| 4392: |
| 4393: std :: string XmlUnitTestResultPrinter :: TestPropertiesAsXmlAttributes ( |
| 4394: const TestResult & result ) { |
| 4395: Message attributes ; |
4396: for/* for (int i = 0; i < result.test_property_count(); ++i) {
const TestProperty& property = result.GetTestProperty(i);
attributes << " " << property.key() << "="
<< "\"" << EscapeXmlAttribute(property.value()) << "\"";
} */ ( int i = 0 ; i < result . test_property_count ( ) ; ++ i ) {/*
const TestProperty& property = result.GetTestProperty(i);
attributes << " " << property.key() << "="
<< "\"" << EscapeXmlAttribute(property.value()) << "\"";
*/ |
| 4397: const TestProperty & property = result . GetTestProperty ( i ) ; |
| 4398: attributes << " " << property . key ( ) << "=" |
| 4399: << "\"" << EscapeXmlAttribute ( property . value ( ) ) << "\"" ; |
| 4400: } |
| 4401: return attributes . GetString ( ) ; |
| 4402: } |
| 4403: |
| 4404: void XmlUnitTestResultPrinter :: OutputXmlTestProperties ( |
| 4405: std :: ostream * stream , const TestResult & result ) {/*
const std::string kProperties = "properties";
const std::string kProperty = "property";
if (result.test_property_count() <= 0) {
return;
}
*stream << "<" << kProperties << ">\n";
for (int i = 0; i < result.test_property_count(); ++i) {
const TestProperty& property = result.GetTestProperty(i);
*stream << "<" << kProperty;
*stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\"";
*stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\"";
*stream << "/>\n";
}
*stream << "</" << kProperties << ">\n";
*/ |
| 4406: const std :: string kProperties = "properties" ; |
| 4407: const std :: string kProperty = "property" ; |
| 4408: |
4409: if/* if (result.test_property_count() <= 0) {
return;
} */ result . test_property_count ( ) <= 0 ) |
| 4410: ; |
| 4411: } |
| 4412: |
4413: */* *stream << "<" << kProperties << ">\n" */ stream << "<" << kProperties << ">\n" ; |
4414: for/* for (int i = 0; i < result.test_property_count(); ++i) {
const TestProperty& property = result.GetTestProperty(i);
*stream << "<" << kProperty;
*stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\"";
*stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\"";
*stream << "/>\n";
} */ ( int i = 0 ; i < result . test_property_count ( ) ; ++ i ) {/*
const TestProperty& property = result.GetTestProperty(i);
*stream << "<" << kProperty;
*stream << " name=\"" << EscapeXmlAttribute(property.key()) << "\"";
*stream << " value=\"" << EscapeXmlAttribute(property.value()) << "\"";
*stream << "/>\n";
*/ |
| 4415: const TestProperty & property = result . GetTestProperty ( i ) ; |
4416: */* *stream << "<" << kProperty */ stream << "<" << kProperty ; |
| 4417: * stream << " name=\"" << EscapeXmlAttribute ( property . key ( ) ) << "\"" ; |
| 4418: * stream << " value=\"" << EscapeXmlAttribute ( property . value ( ) ) << "\"" ; |
| 4419: stream << "/>\n" ; |
| 4420: } |
4421: */* *stream << "</" << kProperties << ">\n" */ stream << "</" << kProperties << ">\n" ; |
| 4422: } |
| 4423: |
| 4424: |
| 4425: |
| 4426: |
| 4427: class JsonUnitTestResultPrinter : public EmptyTestEventListener { |
| 4428: public : |
| 4429: explicit JsonUnitTestResultPrinter ( const char * output_file ) ; |
| 4430: |
| 4431: void OnTestIterationEnd ( const UnitTest & unit_test , int iteration ) override ; |
| 4432: |
| 4433: |
| 4434: static void PrintJsonTestList ( :: std :: ostream * stream , |
| 4435: const std :: vector < TestSuite * > & test_suites ) ; |
| 4436: |
| 4437: private : |
| 4438: |
| 4439: static std :: string EscapeJson ( const std :: string & str ) ; |
| 4440: |
| 4441: |
| 4442: |
| 4443: static void OutputJsonKey ( std :: ostream * stream , |
| 4444: const std :: string & element_name , |
| 4445: const std :: string & name , |
| 4446: const std :: string & value , |
| 4447: const std :: string & indent , |
| 4448: bool comma = true ) ; |
| 4449: static void OutputJsonKey ( std :: ostream * stream , |
| 4450: const std :: string & element_name , |
| 4451: const std :: string & name , |
| 4452: int value , |
| 4453: const std :: string & indent , |
| 4454: bool comma = true ) ; |
| 4455: |
| 4456: |
| 4457: |
| 4458: |
| 4459: static void OutputJsonTestSuiteForTestResult ( :: std :: ostream * stream , |
| 4460: const TestResult & result ) ; |
| 4461: |
| 4462: |
| 4463: static void OutputJsonTestResult ( :: std :: ostream * stream , |
| 4464: const TestResult & result ) ; |
| 4465: |
| 4466: |
| 4467: static void OutputJsonTestInfo ( :: std :: ostream * stream , |
| 4468: const char * test_suite_name , |
| 4469: const TestInfo & test_info ) ; |
| 4470: |
| 4471: |
| 4472: static void PrintJsonTestSuite ( :: std :: ostream * stream , |
| 4473: const TestSuite & test_suite ) ; |
| 4474: |
| 4475: |
| 4476: static void PrintJsonUnitTest ( :: std :: ostream * stream , |
| 4477: const UnitTest & unit_test ) ; |
| 4478: |
| 4479: |
| 4480: |
| 4481: static std :: string TestPropertiesAsJson ( const TestResult & result , |
| 4482: const std :: string & indent ) ; |
| 4483: |
| 4484: |
| 4485: const std :: string output_file_ ; |
| 4486: |
| 4487: GTEST_DISALLOW_COPY_AND_ASSIGN_ ( JsonUnitTestResultPrinter ) ; |
| 4488: } ; |
| 4489: |
| 4490: |
| 4491: JsonUnitTestResultPrinter :: JsonUnitTestResultPrinter ( const char * output_file ) |
| 4492: : output_file_ ( output_file ) {/*
if (output_file_.empty()) {
GTEST_LOG_(FATAL) << "JSON output file may not be null";
}
*/ |
4493: if/* if (output_file_.empty()) {
GTEST_LOG_(FATAL) << "JSON output file may not be null";
} */ output_file_ . empty ( ) ) {/*
GTEST_LOG_(FATAL) << "JSON output file may not be null";
*/ |
| 4494: GTEST_LOG_ ( FATAL ) << "JSON output file may not be null" ; |
| 4495: } |
| 4496: } |
| 4497: |
| 4498: void JsonUnitTestResultPrinter :: OnTestIterationEnd ( const UnitTest & unit_test , |
| 4499: int ) {/*
FILE* jsonout = OpenFileForWriting(output_file_);
std::stringstream stream;
PrintJsonUnitTest(&stream, unit_test);
fprintf(jsonout, "%s", StringStreamToString(&stream).c_str());
fclose(jsonout);
*/ |
| 4500: FILE * jsonout = OpenFileForWriting ( output_file_ ) ; |
| 4501: std :: stringstream stream ; |
4502: PrintJsonUnitTest/* PrintJsonUnitTest(&stream, unit_test) */ ( & stream , unit_test ) ; |
| 4503: fprintf ( jsonout , "%s" , StringStreamToString ( & stream ) . c_str ( ) ) ; |
4504: fclose/* fclose(jsonout) */ ( jsonout ) ; |
| 4505: } |
| 4506: |
| 4507: |
| 4508: std :: string JsonUnitTestResultPrinter :: EscapeJson ( const std :: string & str ) { |
| 4509: Message m ; |
| 4510: |
4511: for/* for (size_t i = 0; i < str.size(); ++i) {
const char ch = str[i];
switch (ch) {
case '\\':
case '"':
case '/':
m << '\\' << ch;
break;
case '\b':
m << "\\b";
break;
case '\t':
m << "\\t";
break;
case '\n':
m << "\\n";
break;
case '\f':
m << "\\f";
break;
case '\r':
m << "\\r";
break;
default:
if (ch < ' ') {
m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
} else {
m << ch;
}
break;
}
} */ ( size_t i = 0 ; i < str . size ( ) ; ++ i ) {/*
const char ch = str[i];
switch (ch) {
case '\\':
case '"':
case '/':
m << '\\' << ch;
break;
case '\b':
m << "\\b";
break;
case '\t':
m << "\\t";
break;
case '\n':
m << "\\n";
break;
case '\f':
m << "\\f";
break;
case '\r':
m << "\\r";
break;
default:
if (ch < ' ') {
m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
} else {
m << ch;
}
break;
}
*/ |
| 4512: const char ch = str [ i ] ; |
4513: switch/* switch (ch) {
case '\\':
case '"':
case '/':
m << '\\' << ch;
break;
case '\b':
m << "\\b";
break;
case '\t':
m << "\\t";
break;
case '\n':
m << "\\n";
break;
case '\f':
m << "\\f";
break;
case '\r':
m << "\\r";
break;
default:
if (ch < ' ') {
m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
} else {
m << ch;
}
break;
} */ ( ch ) { |
| 4514: case '\\' : |
| 4515: case '"' : |
| 4516: case '/' : |
| 4517: m << '\\' << ch ; |
| 4518: break ; |
| 4519: case '\b' : |
| 4520: << "\\b" ; |
| 4521: break ; |
| 4522: case '\t' : |
| 4523: << "\\t" ; |
| 4524: break ; |
| 4525: case '\n' : |
| 4526: << "\\n" ; |
| 4527: break ; |
| 4528: case '\f' : |
| 4529: << "\\f" ; |
| 4530: break ; |
| 4531: case '\r' : |
| 4532: << "\\r" ; |
| 4533: break ; |
| 4534: default : |
4535: if/* if (ch < ' ') {
m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
} else {
m << ch;
} */ ch < ' ' ) {/*
m << "\\u00" << String::FormatByte(static_cast<unsigned char>(ch));
*/ |
| 4536: m << "\\u00" << String :: FormatByte ( static_cast < unsigned char > ( ch ) ) ; |
| 4537: } else |
| 4538: << ch ; |
| 4539: } |
| 4540: break ; |
| 4541: } |
| 4542: } |
| 4543: |
| 4544: return m . GetString ( ) ; |
| 4545: } |
| 4546: |
| 4547: |
| 4548: |
| 4549: |
| 4550: |
| 4551: static std :: string FormatTimeInMillisAsDuration ( TimeInMillis ms ) { |
| 4552: :: std :: stringstream ss ; |
4553: ss/* ss << (static_cast<double>(ms) * 1e-3) << "s" */ << ( static_cast < double > ( ms ) * 1e-3 ) << "s" ; |
| 4554: return ss . str ( ) ; |
| 4555: } |
| 4556: |
| 4557: |
| 4558: |
| 4559: static std :: string FormatEpochTimeInMillisAsRFC3339 ( TimeInMillis ms ) { |
| 4560: struct tm time_struct ; |
| 4561: if (truefalse!!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct) ! PortableLocaltime ( static_cast < time_t > ( ms / 1000 ) , & time_struct ) ) |
| 4562: return "" ; |
| 4563: |
| 4564: return StreamableToString ( time_struct . tm_year + 1900 ) + "-" + |
| 4565: String :: FormatIntWidth2 ( time_struct . tm_mon + 1 ) + "-" + |
| 4566: String :: FormatIntWidth2 ( time_struct . tm_mday ) + "T" + |
| 4567: String :: FormatIntWidth2 ( time_struct . tm_hour ) + ":" + |
| 4568: String :: FormatIntWidth2 ( time_struct . tm_min ) + ":" + |
| 4569: String :: FormatIntWidth2 ( time_struct . tm_sec ) + "Z" ; |
| 4570: } |
| 4571: |
| 4572: static inline std :: string Indent ( size_t width ) { |
| 4573: return std :: string ( width , ' ' ) ; |
| 4574: } |
| 4575: |
| 4576: void JsonUnitTestResultPrinter :: OutputJsonKey ( |
| 4577: std :: ostream * stream , |
| 4578: const std :: string & element_name , |
| 4579: const std :: string & name , |
| 4580: const std :: string & value , |
| 4581: const std :: string & indent , |
| 4582: bool comma ) {/*
const std::vector<std::string>& allowed_names =
GetReservedOutputAttributesForElement(element_name);
GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
allowed_names.end())
<< "Key \"" << name << "\" is not allowed for value \"" << element_name
<< "\".";
*stream << indent << "\"" << name << "\": \"" << EscapeJson(value) << "\"";
if (comma)
*stream << ",\n";
*/ |
| 4583: const std :: vector < std :: string > & allowed_names = |
| 4584: GetReservedOutputAttributesForElement ( element_name ) ; |
| 4585: |
| 4586: GTEST_CHECK_ ( std :: find ( allowed_names . begin ( ) , allowed_names . end ( ) , name ) != |
| 4587: allowed_names . end ( ) ) |
| 4588: << "Key \"" << name << "\" is not allowed for value \"" << element_name |
| 4589: << "\"." ; |
| 4590: |
| 4591: * stream << indent << "\"" << name << "\": \"" << EscapeJson ( value ) << "\"" ; |
4592: if/* if (comma)
*stream << ",\n" */ comma ) |
| 4593: * stream << ",\n" ; |
| 4594: } |
| 4595: |
| 4596: void JsonUnitTestResultPrinter :: OutputJsonKey ( |
| 4597: std :: ostream * stream , |
| 4598: const std :: string & element_name , |
| 4599: const std :: string & name , |
| 4600: int value , |
| 4601: const std :: string & indent , |
| 4602: bool comma ) {/*
const std::vector<std::string>& allowed_names =
GetReservedOutputAttributesForElement(element_name);
GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
allowed_names.end())
<< "Key \"" << name << "\" is not allowed for value \"" << element_name
<< "\".";
*stream << indent << "\"" << name << "\": " << StreamableToString(value);
if (comma)
*stream << ",\n";
*/ |
| 4603: const std :: vector < std :: string > & allowed_names = |
| 4604: GetReservedOutputAttributesForElement ( element_name ) ; |
| 4605: |
| 4606: GTEST_CHECK_ ( std :: find ( allowed_names . begin ( ) , allowed_names . end ( ) , name ) != |
| 4607: allowed_names . end ( ) ) |
| 4608: << "Key \"" << name << "\" is not allowed for value \"" << element_name |
| 4609: << "\"." ; |
| 4610: |
| 4611: * stream << indent << "\"" << name << "\": " << StreamableToString ( value ) ; |
4612: if/* if (comma)
*stream << ",\n" */ comma ) |
| 4613: * stream << ",\n" ; |
| 4614: } |
| 4615: |
| 4616: |
| 4617: void JsonUnitTestResultPrinter :: OutputJsonTestSuiteForTestResult ( |
| 4618: :: std :: ostream * stream , const TestResult & result ) {/*
// Output the boilerplate for a new test suite.
*stream << Indent(4) << "{\n";
OutputJsonKey(stream, "testsuite", "name", "NonTestSuiteFailure", Indent(6));
OutputJsonKey(stream, "testsuite", "tests", 1, Indent(6));
if (!GTEST_FLAG(list_tests)) {
OutputJsonKey(stream, "testsuite", "failures", 1, Indent(6));
OutputJsonKey(stream, "testsuite", "disabled", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "skipped", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "errors", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "time",
FormatTimeInMillisAsDuration(result.elapsed_time()),
Indent(6));
OutputJsonKey(stream, "testsuite", "timestamp",
FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
Indent(6));
}
*stream << Indent(6) << "\"testsuite\": [\n";
// Output the boilerplate for a new test case.
*stream << Indent(8) << "{\n";
OutputJsonKey(stream, "testcase", "name", "", Indent(10));
OutputJsonKey(stream, "testcase", "status", "RUN", Indent(10));
OutputJsonKey(stream, "testcase", "result", "COMPLETED", Indent(10));
OutputJsonKey(stream, "testcase", "timestamp",
FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
Indent(10));
OutputJsonKey(stream, "testcase", "time",
FormatTimeInMillisAsDuration(result.elapsed_time()),
Indent(10));
OutputJsonKey(stream, "testcase", "classname", "", Indent(10), false);
*stream << TestPropertiesAsJson(result, Indent(10));
// Output the actual test result.
OutputJsonTestResult(stream, result);
// Finish the test suite.
*stream << "\n" << Indent(6) << "]\n" << Indent(4) << "}";
*/ |
| 4619: |
| 4620: * stream << Indent ( 4 ) << "{\n" ; |
| 4621: OutputJsonKey ( stream , "testsuite" , "name" , "NonTestSuiteFailure" , Indent ( 6 ) ) ; |
| 4622: OutputJsonKey ( stream , "testsuite" , "tests" , 1 , Indent ( 6 ) ) ; |
4623: if/* if (!GTEST_FLAG(list_tests)) {
OutputJsonKey(stream, "testsuite", "failures", 1, Indent(6));
OutputJsonKey(stream, "testsuite", "disabled", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "skipped", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "errors", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "time",
FormatTimeInMillisAsDuration(result.elapsed_time()),
Indent(6));
OutputJsonKey(stream, "testsuite", "timestamp",
FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
Indent(6));
} */ (truefalse!!GTEST_FLAG(list_tests) ! GTEST_FLAG ( list_tests ) ) {/*
OutputJsonKey(stream, "testsuite", "failures", 1, Indent(6));
OutputJsonKey(stream, "testsuite", "disabled", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "skipped", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "errors", 0, Indent(6));
OutputJsonKey(stream, "testsuite", "time",
FormatTimeInMillisAsDuration(result.elapsed_time()),
Indent(6));
OutputJsonKey(stream, "testsuite", "timestamp",
FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
Indent(6));
*/ |
| 4624: OutputJsonKey ( stream , "testsuite" , "failures" , 1 , Indent ( 6 ) ) ; |
| 4625: OutputJsonKey ( stream , "testsuite" , "disabled" , 0 , Indent ( 6 ) ) ; |
| 4626: OutputJsonKey ( stream , "testsuite" , "skipped" , 0 , Indent ( 6 ) ) ; |
| 4627: OutputJsonKey ( stream , "testsuite" , "errors" , 0 , Indent ( 6 ) ) ; |
| 4628: OutputJsonKey ( stream , "testsuite" , "time" , |
| 4629: FormatTimeInMillisAsDuration ( result . elapsed_time ( ) ) , |
| 4630: Indent ( 6 ) ) ; |
| 4631: OutputJsonKey ( stream , "testsuite" , "timestamp" , |
| 4632: FormatEpochTimeInMillisAsRFC3339 ( result . start_timestamp ( ) ) , |
| 4633: Indent ( 6 ) ) ; |
| 4634: } |
| 4635: * stream << Indent ( 6 ) << "\"testsuite\": [\n" ; |
| 4636: |
| 4637: |
| 4638: * stream << Indent ( 8 ) << "{\n" ; |
| 4639: OutputJsonKey ( stream , "testcase" , "name" , "" , Indent ( 10 ) ) ; |
| 4640: OutputJsonKey ( stream , "testcase" , "status" , "RUN" , Indent ( 10 ) ) ; |
| 4641: OutputJsonKey ( stream , "testcase" , "result" , "COMPLETED" , Indent ( 10 ) ) ; |
| 4642: OutputJsonKey ( stream , "testcase" , "timestamp" , |
| 4643: FormatEpochTimeInMillisAsRFC3339 ( result . start_timestamp ( ) ) , |
| 4644: Indent ( 10 ) ) ; |
| 4645: OutputJsonKey ( stream , "testcase" , "time" , |
| 4646: FormatTimeInMillisAsDuration ( result . elapsed_time ( ) ) , |
| 4647: Indent ( 10 ) ) ; |
| 4648: OutputJsonKey ( stream , "testcase" , "classname" , "" , Indent ( 10 ) , false ) ; |
| 4649: * stream << TestPropertiesAsJson ( result , Indent ( 10 ) ) ; |
| 4650: |
| 4651: |
4652: OutputJsonTestResult/* OutputJsonTestResult(stream, result) */ ( stream , result ) ; |
| 4653: |
| 4654: |
| 4655: * stream << "\n" << Indent ( 6 ) << "]\n" << Indent ( 4 ) << "}" ; |
| 4656: } |
| 4657: |
| 4658: |
| 4659: void JsonUnitTestResultPrinter :: OutputJsonTestInfo ( :: std :: ostream * stream , |
| 4660: const char * test_suite_name , |
| 4661: const TestInfo & test_info ) {/*
const TestResult& result = *test_info.result();
const std::string kTestsuite = "testcase";
const std::string kIndent = Indent(10);
*stream << Indent(8) << "{\n";
OutputJsonKey(stream, kTestsuite, "name", test_info.name(), kIndent);
if (test_info.value_param() != nullptr) {
OutputJsonKey(stream, kTestsuite, "value_param", test_info.value_param(),
kIndent);
}
if (test_info.type_param() != nullptr) {
OutputJsonKey(stream, kTestsuite, "type_param", test_info.type_param(),
kIndent);
}
if (GTEST_FLAG(list_tests)) {
OutputJsonKey(stream, kTestsuite, "file", test_info.file(), kIndent);
OutputJsonKey(stream, kTestsuite, "line", test_info.line(), kIndent, false);
*stream << "\n" << Indent(8) << "}";
return;
}
OutputJsonKey(stream, kTestsuite, "status",
test_info.should_run() ? "RUN" : "NOTRUN", kIndent);
OutputJsonKey(stream, kTestsuite, "result",
test_info.should_run()
? (result.Skipped() ? "SKIPPED" : "COMPLETED")
: "SUPPRESSED",
kIndent);
OutputJsonKey(stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsRFC3339(result.start_timestamp()),
kIndent);
OutputJsonKey(stream, kTestsuite, "time",
FormatTimeInMillisAsDuration(result.elapsed_time()), kIndent);
OutputJsonKey(stream, kTestsuite, "classname", test_suite_name, kIndent,
false);
*stream << TestPropertiesAsJson(result, kIndent);
OutputJsonTestResult(stream, result);
*/ |
| 4662: const TestResult & result = * test_info . result ( ) ; |
| 4663: const std :: string kTestsuite = "testcase" ; |
| 4664: const std :: string kIndent = Indent ( 10 ) ; |
| 4665: |
| 4666: * stream << Indent ( 8 ) << "{\n" ; |
| 4667: OutputJsonKey ( stream , kTestsuite , "name" , test_info . name ( ) , kIndent ) ; |
| 4668: |
4669: if/* if (test_info.value_param() != nullptr) {
OutputJsonKey(stream, kTestsuite, "value_param", test_info.value_param(),
kIndent);
} */ test_info . value_param ( ) != nullptr ) {/*
OutputJsonKey(stream, kTestsuite, "value_param", test_info.value_param(),
kIndent);
*/ |
| 4670: OutputJsonKey ( stream , kTestsuite , "value_param" , test_info . value_param ( ) , |
| 4671: kIndent ) ; |
| 4672: } |
4673: if/* if (test_info.type_param() != nullptr) {
OutputJsonKey(stream, kTestsuite, "type_param", test_info.type_param(),
kIndent);
} */ test_info . type_param ( ) != nullptr ) {/*
OutputJsonKey(stream, kTestsuite, "type_param", test_info.type_param(),
kIndent);
*/ |
| 4674: OutputJsonKey ( stream , kTestsuite , "type_param" , test_info . type_param ( ) , |
| 4675: kIndent ) ; |
| 4676: } |
4677: if/* if (GTEST_FLAG(list_tests)) {
OutputJsonKey(stream, kTestsuite, "file", test_info.file(), kIndent);
OutputJsonKey(stream, kTestsuite, "line", test_info.line(), kIndent, false);
*stream << "\n" << Indent(8) << "}";
return;
} */ ( GTEST_FLAG ( list_tests ) ) {/*
OutputJsonKey(stream, kTestsuite, "file", test_info.file(), kIndent);
OutputJsonKey(stream, kTestsuite, "line", test_info.line(), kIndent, false);
*stream << "\n" << Indent(8) << "}";
return;
*/ |
| 4678: OutputJsonKey ( stream , kTestsuite , "file" , test_info . file ( ) , kIndent ) ; |
| 4679: OutputJsonKey ( stream , kTestsuite , "line" , test_info . line ( ) , kIndent , false ) ; |
| 4680: * stream << "\n" << Indent ( 8 ) << "}" ; |
| 4681: ; |
| 4682: } |
| 4683: |
| 4684: OutputJsonKey ( stream , kTestsuite , "status" , |
| 4685: test_info . should_run ( ) ? "RUN" : "NOTRUN" , kIndent ) ; |
| 4686: OutputJsonKey ( stream , kTestsuite , "result" , |
| 4687: test_info . should_run ( ) |
| 4688: ? ( result . Skipped ( ) ? "SKIPPED" : "COMPLETED" ) |
| 4689: : "SUPPRESSED" , |
| 4690: kIndent ) ; |
| 4691: OutputJsonKey ( stream , kTestsuite , "timestamp" , |
| 4692: FormatEpochTimeInMillisAsRFC3339 ( result . start_timestamp ( ) ) , |
| 4693: kIndent ) ; |
| 4694: OutputJsonKey ( stream , kTestsuite , "time" , |
| 4695: FormatTimeInMillisAsDuration ( result . elapsed_time ( ) ) , kIndent ) ; |
| 4696: OutputJsonKey ( stream , kTestsuite , "classname" , test_suite_name , kIndent , |
| 4697: false ) ; |
| 4698: * stream << TestPropertiesAsJson ( result , kIndent ) ; |
| 4699: |
4700: OutputJsonTestResult/* OutputJsonTestResult(stream, result) */ ( stream , result ) ; |
| 4701: } |
| 4702: |
| 4703: void JsonUnitTestResultPrinter :: OutputJsonTestResult ( :: std :: ostream * stream , |
| 4704: const TestResult & result ) {/*
const std::string kIndent = Indent(10);
int failures = 0;
for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
if (part.failed()) {
*stream << ",\n";
if (++failures == 1) {
*stream << kIndent << "\"" << "failures" << "\": [\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string message = EscapeJson(location + "\n" + part.message());
*stream << kIndent << " {\n"
<< kIndent << " \"failure\": \"" << message << "\",\n"
<< kIndent << " \"type\": \"\"\n"
<< kIndent << " }";
}
}
if (failures > 0)
*stream << "\n" << kIndent << "]";
*stream << "\n" << Indent(8) << "}";
*/ |
| 4705: const std :: string kIndent = Indent ( 10 ) ; |
| 4706: |
| 4707: int failures = 0 ; |
4708: for/* for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
if (part.failed()) {
*stream << ",\n";
if (++failures == 1) {
*stream << kIndent << "\"" << "failures" << "\": [\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string message = EscapeJson(location + "\n" + part.message());
*stream << kIndent << " {\n"
<< kIndent << " \"failure\": \"" << message << "\",\n"
<< kIndent << " \"type\": \"\"\n"
<< kIndent << " }";
}
} */ ( int i = 0 ; i < result . total_part_count ( ) ; ++ i ) {/*
const TestPartResult& part = result.GetTestPartResult(i);
if (part.failed()) {
*stream << ",\n";
if (++failures == 1) {
*stream << kIndent << "\"" << "failures" << "\": [\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string message = EscapeJson(location + "\n" + part.message());
*stream << kIndent << " {\n"
<< kIndent << " \"failure\": \"" << message << "\",\n"
<< kIndent << " \"type\": \"\"\n"
<< kIndent << " }";
}
*/ |
| 4709: const TestPartResult & part = result . GetTestPartResult ( i ) ; |
4710: if/* if (part.failed()) {
*stream << ",\n";
if (++failures == 1) {
*stream << kIndent << "\"" << "failures" << "\": [\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string message = EscapeJson(location + "\n" + part.message());
*stream << kIndent << " {\n"
<< kIndent << " \"failure\": \"" << message << "\",\n"
<< kIndent << " \"type\": \"\"\n"
<< kIndent << " }";
} */ part . failed ( ) ) {/*
*stream << ",\n";
if (++failures == 1) {
*stream << kIndent << "\"" << "failures" << "\": [\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string message = EscapeJson(location + "\n" + part.message());
*stream << kIndent << " {\n"
<< kIndent << " \"failure\": \"" << message << "\",\n"
<< kIndent << " \"type\": \"\"\n"
<< kIndent << " }";
*/ |
| 4711: stream << ",\n" ; |
4712: if/* if (++failures == 1) {
*stream << kIndent << "\"" << "failures" << "\": [\n";
} */ ++ failures == 1 ) {/*
*stream << kIndent << "\"" << "failures" << "\": [\n";
*/ |
4713: */* *stream << kIndent << "\"" << "failures" << "\": [\n" */ stream << kIndent << "\"" << "failures" << "\": [\n" ; |
| 4714: } |
| 4715: const std :: string location = |
| 4716: internal :: FormatCompilerIndependentFileLocation ( part . file_name ( ) , |
| 4717: part . line_number ( ) ) ; |
| 4718: const std :: string message = EscapeJson ( location + "\n" + part . message ( ) ) ; |
4719: */* *stream << kIndent << " {\n"
<< kIndent << " \"failure\": \"" << message << "\",\n"
<< kIndent << " \"type\": \"\"\n"
<< kIndent << " }" */ stream << kIndent << " {\n" |
| 4720: << kIndent << " \"failure\": \"" << message << "\",\n" |
| 4721: << kIndent << " \"type\": \"\"\n" |
| 4722: << kIndent << " }" ; |
| 4723: } |
| 4724: } |
| 4725: |
4726: if/* if (failures > 0)
*stream << "\n" << kIndent << "]" */ failures > 0 ) |
| 4727: * stream << "\n" << kIndent << "]" ; |
| 4728: * stream << "\n" << Indent ( 8 ) << "}" ; |
| 4729: } |
| 4730: |
| 4731: |
| 4732: void JsonUnitTestResultPrinter :: PrintJsonTestSuite ( |
| 4733: std :: ostream * stream , const TestSuite & test_suite ) {/*
const std::string kTestsuite = "testsuite";
const std::string kIndent = Indent(6);
*stream << Indent(4) << "{\n";
OutputJsonKey(stream, kTestsuite, "name", test_suite.name(), kIndent);
OutputJsonKey(stream, kTestsuite, "tests", test_suite.reportable_test_count(),
kIndent);
if (!GTEST_FLAG(list_tests)) {
OutputJsonKey(stream, kTestsuite, "failures",
test_suite.failed_test_count(), kIndent);
OutputJsonKey(stream, kTestsuite, "disabled",
test_suite.reportable_disabled_test_count(), kIndent);
OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent);
OutputJsonKey(
stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsRFC3339(test_suite.start_timestamp()),
kIndent);
OutputJsonKey(stream, kTestsuite, "time",
FormatTimeInMillisAsDuration(test_suite.elapsed_time()),
kIndent, false);
*stream << TestPropertiesAsJson(test_suite.ad_hoc_test_result(), kIndent)
<< ",\n";
}
*stream << kIndent << "\"" << kTestsuite << "\": [\n";
bool comma = false;
for (int i = 0; i < test_suite.total_test_count(); ++i) {
if (test_suite.GetTestInfo(i)->is_reportable()) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
}
}
*stream << "\n" << kIndent << "]\n" << Indent(4) << "}";
*/ |
| 4734: const std :: string kTestsuite = "testsuite" ; |
| 4735: const std :: string kIndent = Indent ( 6 ) ; |
| 4736: |
| 4737: * stream << Indent ( 4 ) << "{\n" ; |
| 4738: OutputJsonKey ( stream , kTestsuite , "name" , test_suite . name ( ) , kIndent ) ; |
| 4739: OutputJsonKey ( stream , kTestsuite , "tests" , test_suite . reportable_test_count ( ) , |
| 4740: kIndent ) ; |
4741: if/* if (!GTEST_FLAG(list_tests)) {
OutputJsonKey(stream, kTestsuite, "failures",
test_suite.failed_test_count(), kIndent);
OutputJsonKey(stream, kTestsuite, "disabled",
test_suite.reportable_disabled_test_count(), kIndent);
OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent);
OutputJsonKey(
stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsRFC3339(test_suite.start_timestamp()),
kIndent);
OutputJsonKey(stream, kTestsuite, "time",
FormatTimeInMillisAsDuration(test_suite.elapsed_time()),
kIndent, false);
*stream << TestPropertiesAsJson(test_suite.ad_hoc_test_result(), kIndent)
<< ",\n";
} */ (truefalse!!GTEST_FLAG(list_tests) ! GTEST_FLAG ( list_tests ) ) {/*
OutputJsonKey(stream, kTestsuite, "failures",
test_suite.failed_test_count(), kIndent);
OutputJsonKey(stream, kTestsuite, "disabled",
test_suite.reportable_disabled_test_count(), kIndent);
OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent);
OutputJsonKey(
stream, kTestsuite, "timestamp",
FormatEpochTimeInMillisAsRFC3339(test_suite.start_timestamp()),
kIndent);
OutputJsonKey(stream, kTestsuite, "time",
FormatTimeInMillisAsDuration(test_suite.elapsed_time()),
kIndent, false);
*stream << TestPropertiesAsJson(test_suite.ad_hoc_test_result(), kIndent)
<< ",\n";
*/ |
| 4742: OutputJsonKey ( stream , kTestsuite , "failures" , |
| 4743: test_suite . failed_test_count ( ) , kIndent ) ; |
| 4744: OutputJsonKey ( stream , kTestsuite , "disabled" , |
| 4745: test_suite . reportable_disabled_test_count ( ) , kIndent ) ; |
| 4746: OutputJsonKey ( stream , kTestsuite , "errors" , 0 , kIndent ) ; |
| 4747: OutputJsonKey ( |
| 4748: stream , kTestsuite , "timestamp" , |
| 4749: FormatEpochTimeInMillisAsRFC3339 ( test_suite . start_timestamp ( ) ) , |
| 4750: kIndent ) ; |
| 4751: OutputJsonKey ( stream , kTestsuite , "time" , |
| 4752: FormatTimeInMillisAsDuration ( test_suite . elapsed_time ( ) ) , |
| 4753: kIndent , false ) ; |
| 4754: * stream << TestPropertiesAsJson ( test_suite . ad_hoc_test_result ( ) , kIndent ) |
| 4755: << ",\n" ; |
| 4756: } |
| 4757: |
4758: */* *stream << kIndent << "\"" << kTestsuite << "\": [\n" */ stream << kIndent << "\"" << kTestsuite << "\": [\n" ; |
| 4759: |
| 4760: bool comma = false ; |
4761: for/* for (int i = 0; i < test_suite.total_test_count(); ++i) {
if (test_suite.GetTestInfo(i)->is_reportable()) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
}
} */ ( int i = 0 ; i < test_suite . total_test_count ( ) ; ++ i ) {/*
if (test_suite.GetTestInfo(i)->is_reportable()) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
}
*/ |
4762: if/* if (test_suite.GetTestInfo(i)->is_reportable()) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
} */ test_suite . GetTestInfo ( i ) -> is_reportable ( ) ) {/*
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i));
*/ |
4763: if/* if (comma) {
*stream << ",\n";
} else {
comma = true;
} */ comma ) |
| 4764: stream << ",\n" ; |
| 4765: } else |
| 4766: = true ; |
| 4767: } |
4768: OutputJsonTestInfo/* OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i)) */ ( stream , test_suite . name ( ) , * test_suite . GetTestInfo ( i ) ) ; |
| 4769: } |
| 4770: } |
| 4771: * stream << "\n" << kIndent << "]\n" << Indent ( 4 ) << "}" ; |
| 4772: } |
| 4773: |
| 4774: |
| 4775: void JsonUnitTestResultPrinter :: PrintJsonUnitTest ( std :: ostream * stream , |
| 4776: const UnitTest & unit_test ) {/*
const std::string kTestsuites = "testsuites";
const std::string kIndent = Indent(2);
*stream << "{\n";
OutputJsonKey(stream, kTestsuites, "tests", unit_test.reportable_test_count(),
kIndent);
OutputJsonKey(stream, kTestsuites, "failures", unit_test.failed_test_count(),
kIndent);
OutputJsonKey(stream, kTestsuites, "disabled",
unit_test.reportable_disabled_test_count(), kIndent);
OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent);
if (GTEST_FLAG(shuffle)) {
OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(),
kIndent);
}
OutputJsonKey(stream, kTestsuites, "timestamp",
FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()),
kIndent);
OutputJsonKey(stream, kTestsuites, "time",
FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent,
false);
*stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent)
<< ",\n";
OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent);
*stream << kIndent << "\"" << kTestsuites << "\": [\n";
bool comma = false;
for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));
}
}
// If there was a test failure outside of one of the test suites (like in a
// test environment) include that in the output.
if (unit_test.ad_hoc_test_result().Failed()) {
OutputJsonTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
}
*stream << "\n" << kIndent << "]\n" << "}\n";
*/ |
| 4777: const std :: string kTestsuites = "testsuites" ; |
| 4778: const std :: string kIndent = Indent ( 2 ) ; |
| 4779: stream << "{\n" ; |
| 4780: |
| 4781: OutputJsonKey ( stream , kTestsuites , "tests" , unit_test . reportable_test_count ( ) , |
| 4782: kIndent ) ; |
| 4783: OutputJsonKey ( stream , kTestsuites , "failures" , unit_test . failed_test_count ( ) , |
| 4784: kIndent ) ; |
| 4785: OutputJsonKey ( stream , kTestsuites , "disabled" , |
| 4786: unit_test . reportable_disabled_test_count ( ) , kIndent ) ; |
| 4787: OutputJsonKey ( stream , kTestsuites , "errors" , 0 , kIndent ) ; |
4788: if/* if (GTEST_FLAG(shuffle)) {
OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(),
kIndent);
} */ ( GTEST_FLAG ( shuffle ) ) {/*
OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(),
kIndent);
*/ |
| 4789: OutputJsonKey ( stream , kTestsuites , "random_seed" , unit_test . random_seed ( ) , |
| 4790: kIndent ) ; |
| 4791: } |
| 4792: OutputJsonKey ( stream , kTestsuites , "timestamp" , |
| 4793: FormatEpochTimeInMillisAsRFC3339 ( unit_test . start_timestamp ( ) ) , |
| 4794: kIndent ) ; |
| 4795: OutputJsonKey ( stream , kTestsuites , "time" , |
| 4796: FormatTimeInMillisAsDuration ( unit_test . elapsed_time ( ) ) , kIndent , |
| 4797: false ) ; |
| 4798: |
| 4799: * stream << TestPropertiesAsJson ( unit_test . ad_hoc_test_result ( ) , kIndent ) |
| 4800: << ",\n" ; |
| 4801: |
| 4802: OutputJsonKey ( stream , kTestsuites , "name" , "AllTests" , kIndent ) ; |
4803: */* *stream << kIndent << "\"" << kTestsuites << "\": [\n" */ stream << kIndent << "\"" << kTestsuites << "\": [\n" ; |
| 4804: |
| 4805: bool comma = false ; |
4806: for/* for (int i = 0; i < unit_test.total_test_suite_count(); ++i) {
if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));
}
} */ ( int i = 0 ; i < unit_test . total_test_suite_count ( ) ; ++ i ) {/*
if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));
}
*/ |
4807: if/* if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) {
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));
} */ unit_test . GetTestSuite ( i ) -> reportable_test_count ( ) > 0 ) {/*
if (comma) {
*stream << ",\n";
} else {
comma = true;
}
PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i));
*/ |
4808: if/* if (comma) {
*stream << ",\n";
} else {
comma = true;
} */ comma ) |
| 4809: stream << ",\n" ; |
| 4810: } else |
| 4811: = true ; |
| 4812: } |
4813: PrintJsonTestSuite/* PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i)) */ ( stream , * unit_test . GetTestSuite ( i ) ) ; |
| 4814: } |
| 4815: } |
| 4816: |
| 4817: |
| 4818: |
4819: if/* if (unit_test.ad_hoc_test_result().Failed()) {
OutputJsonTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
} */ unit_test . ad_hoc_test_result ( ) . Failed ( ) ) {/*
OutputJsonTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result());
*/ |
4820: OutputJsonTestSuiteForTestResult/* OutputJsonTestSuiteForTestResult(stream, unit_test.ad_hoc_test_result()) */ ( stream , unit_test . ad_hoc_test_result ( ) ) ; |
| 4821: } |
| 4822: |
4823: */* *stream << "\n" << kIndent << "]\n" << "}\n" */ stream << "\n" << kIndent << "]\n" << "}\n" ; |
| 4824: } |
| 4825: |
| 4826: void JsonUnitTestResultPrinter :: PrintJsonTestList ( |
| 4827: std :: ostream * stream , const std :: vector < TestSuite * > & test_suites ) {/*
const std::string kTestsuites = "testsuites";
const std::string kIndent = Indent(2);
*stream << "{\n";
int total_tests = 0;
for (auto test_suite : test_suites) {
total_tests += test_suite->total_test_count();
}
OutputJsonKey(stream, kTestsuites, "tests", total_tests, kIndent);
OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent);
*stream << kIndent << "\"" << kTestsuites << "\": [\n";
for (size_t i = 0; i < test_suites.size(); ++i) {
if (i != 0) {
*stream << ",\n";
}
PrintJsonTestSuite(stream, *test_suites[i]);
}
*stream << "\n"
<< kIndent << "]\n"
<< "}\n";
*/ |
| 4828: const std :: string kTestsuites = "testsuites" ; |
| 4829: const std :: string kIndent = Indent ( 2 ) ; |
| 4830: stream << "{\n" ; |
| 4831: int total_tests = 0 ; |
4832: for/* for (auto test_suite : test_suites) {
total_tests += test_suite->total_test_count();
} */ ( auto test_suite : test_suites ) {/*
total_tests += test_suite->total_test_count();
*/ |
4833: total_tests/* total_tests += test_suite->total_test_count() */ += test_suite -> total_test_count ( ) ; |
| 4834: } |
| 4835: OutputJsonKey ( stream , kTestsuites , "tests" , total_tests , kIndent ) ; |
| 4836: |
| 4837: OutputJsonKey ( stream , kTestsuites , "name" , "AllTests" , kIndent ) ; |
4838: */* *stream << kIndent << "\"" << kTestsuites << "\": [\n" */ stream << kIndent << "\"" << kTestsuites << "\": [\n" ; |
| 4839: |
4840: for/* for (size_t i = 0; i < test_suites.size(); ++i) {
if (i != 0) {
*stream << ",\n";
}
PrintJsonTestSuite(stream, *test_suites[i]);
} */ ( size_t i = 0 ; i < test_suites . size ( ) ; ++ i ) {/*
if (i != 0) {
*stream << ",\n";
}
PrintJsonTestSuite(stream, *test_suites[i]);
*/ |
4841: if/* if (i != 0) {
*stream << ",\n";
} */ i != 0 ) |
| 4842: stream << ",\n" ; |
| 4843: } |
4844: PrintJsonTestSuite/* PrintJsonTestSuite(stream, *test_suites[i]) */ ( stream , * test_suites [ i ] ) ; |
| 4845: } |
| 4846: |
4847: */* *stream << "\n"
<< kIndent << "]\n"
<< "}\n" */ stream << "\n" |
| 4848: << kIndent << "]\n" |
| 4849: << "}\n" ; |
| 4850: } |
| 4851: |
| 4852: |
| 4853: std :: string JsonUnitTestResultPrinter :: TestPropertiesAsJson ( |
| 4854: const TestResult & result , const std :: string & indent ) { |
| 4855: Message attributes ; |
4856: for/* for (int i = 0; i < result.test_property_count(); ++i) {
const TestProperty& property = result.GetTestProperty(i);
attributes << ",\n" << indent << "\"" << property.key() << "\": "
<< "\"" << EscapeJson(property.value()) << "\"";
} */ ( int i = 0 ; i < result . test_property_count ( ) ; ++ i ) {/*
const TestProperty& property = result.GetTestProperty(i);
attributes << ",\n" << indent << "\"" << property.key() << "\": "
<< "\"" << EscapeJson(property.value()) << "\"";
*/ |
| 4857: const TestProperty & property = result . GetTestProperty ( i ) ; |
| 4858: attributes << ",\n" << indent << "\"" << property . key ( ) << "\": " |
| 4859: << "\"" << EscapeJson ( property . value ( ) ) << "\"" ; |
| 4860: } |
| 4861: return attributes . GetString ( ) ; |
| 4862: } |
| 4863: |
| 4864: |
| 4865: |
| 4866: # if GTEST_CAN_STREAM_RESULTS_ |
| 4867: |
| 4868: |
| 4869: |
| 4870: |
| 4871: |
| 4872: |
| 4873: std :: string StreamingListener :: UrlEncode ( const char * str ) { |
| 4874: std :: string result ; |
4875: result/* result.reserve(strlen(str) + 1) */ . reserve ( strlen ( str ) + 1 ) ; |
4876: for/* for (char ch = *str; ch != '\0'; ch = *++str) {
switch (ch) {
case '%':
case '=':
case '&':
case '\n':
result.append("%" + String::FormatByte(static_cast<unsigned char>(ch)));
break;
default:
result.push_back(ch);
break;
}
} */ ( char ch = * str ; ch != '\0' ; ch = * ++ str ) {/*
switch (ch) {
case '%':
case '=':
case '&':
case '\n':
result.append("%" + String::FormatByte(static_cast<unsigned char>(ch)));
break;
default:
result.push_back(ch);
break;
}
*/ |
4877: switch/* switch (ch) {
case '%':
case '=':
case '&':
case '\n':
result.append("%" + String::FormatByte(static_cast<unsigned char>(ch)));
break;
default:
result.push_back(ch);
break;
} */ ( ch ) { |
| 4878: case '%' : |
| 4879: case '=' : |
| 4880: case '&' : |
| 4881: case '\n' : |
| 4882: result . append ( "%" + String :: FormatByte ( static_cast < unsigned char > ( ch ) ) ) ; |
| 4883: break ; |
| 4884: default : |
4885: result/* result.push_back(ch) */ . push_back ( ch ) ; |
| 4886: break ; |
| 4887: } |
| 4888: } |
| 4889: return result ; |
| 4890: } |
| 4891: |
| 4892: void StreamingListener :: SocketWriter :: MakeConnection ( ) {/*
GTEST_CHECK_(sockfd_ == -1)
<< "MakeConnection() can't be called when there is already a connection.";
addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses.
hints.ai_socktype = SOCK_STREAM;
addrinfo* servinfo = nullptr;
// Use the getaddrinfo() to get a linked list of IP addresses for
// the given host name.
const int error_num = getaddrinfo(
host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);
if (error_num != 0) {
GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
<< gai_strerror(error_num);
}
// Loop through all the results and connect to the first we can.
for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != nullptr;
cur_addr = cur_addr->ai_next) {
sockfd_ = socket(
cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
if (sockfd_ != -1) {
// Connect the client socket to the server socket.
if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
close(sockfd_);
sockfd_ = -1;
}
}
}
freeaddrinfo(servinfo); // all done with this structure
if (sockfd_ == -1) {
GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
<< host_name_ << ":" << port_num_;
}
*/ |
| 4893: GTEST_CHECK_ ( sockfd_ == - 1 ) |
| 4894: << "MakeConnection() can't be called when there is already a connection." ; |
| 4895: |
| 4896: addrinfo hints ; |
4897: memset/* memset(&hints, 0, sizeof(hints)) */ ( & hints , 0 , sizeof ( hints ) ) ; |
4898: hints/* hints.ai_family = AF_UNSPEC */ . ai_family = AF_UNSPEC ; |
4899: hints/* hints.ai_socktype = SOCK_STREAM */ . ai_socktype = SOCK_STREAM ; |
| 4900: addrinfo * servinfo = nullptr ; |
| 4901: |
| 4902: |
| 4903: |
| 4904: const int error_num = getaddrinfo ( |
| 4905: host_name_ . c_str ( ) , port_num_ . c_str ( ) , & hints , & servinfo ) ; |
4906: if/* if (error_num != 0) {
GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
<< gai_strerror(error_num);
} */ error_num != 0 ) {/*
GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
<< gai_strerror(error_num);
*/ |
| 4907: GTEST_LOG_ ( WARNING ) << "stream_result_to: getaddrinfo() failed: " |
| 4908: << gai_strerror ( error_num ) ; |
| 4909: } |
| 4910: |
| 4911: |
4912: for/* for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != nullptr;
cur_addr = cur_addr->ai_next) {
sockfd_ = socket(
cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
if (sockfd_ != -1) {
// Connect the client socket to the server socket.
if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
close(sockfd_);
sockfd_ = -1;
}
}
} */ ( addrinfo * cur_addr = servinfo ; sockfd_ == - 1 && cur_addr != nullptr ; |
| 4913: cur_addr = cur_addr -> ai_next ) {/*
sockfd_ = socket(
cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
if (sockfd_ != -1) {
// Connect the client socket to the server socket.
if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
close(sockfd_);
sockfd_ = -1;
}
}
*/ |
4914: sockfd_/* sockfd_ = socket(
cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol) */ = socket ( |
| 4915: cur_addr -> ai_family , cur_addr -> ai_socktype , cur_addr -> ai_protocol ) ; |
4916: if/* if (sockfd_ != -1) {
// Connect the client socket to the server socket.
if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
close(sockfd_);
sockfd_ = -1;
}
} */ sockfd_ != - 1 ) {/*
// Connect the client socket to the server socket.
if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
close(sockfd_);
sockfd_ = -1;
}
*/ |
| 4917: |
4918: if/* if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
close(sockfd_);
sockfd_ = -1;
} */ connect ( sockfd_ , cur_addr -> ai_addr , cur_addr -> ai_addrlen ) == - 1 ) {/*
close(sockfd_);
sockfd_ = -1;
*/ |
4919: close/* close(sockfd_) */ ( sockfd_ ) ; |
4920: sockfd_/* sockfd_ = -1 */ = - 1 ; |
| 4921: } |
| 4922: } |
| 4923: } |
| 4924: |
4925: freeaddrinfo/* freeaddrinfo(servinfo) */ ( servinfo ) ; |
| 4926: |
4927: if/* if (sockfd_ == -1) {
GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
<< host_name_ << ":" << port_num_;
} */ sockfd_ == - 1 ) {/*
GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
<< host_name_ << ":" << port_num_;
*/ |
| 4928: GTEST_LOG_ ( WARNING ) << "stream_result_to: failed to connect to " |
| 4929: << host_name_ << ":" << port_num_ ; |
| 4930: } |
| 4931: } |
| 4932: |
| 4933: |
| 4934: # endif |
| 4935: |
| 4936: |
| 4937: |
| 4938: const char * const OsStackTraceGetterInterface :: kElidedFramesMarker = |
| 4939: "... " GTEST_NAME_ " internal frames ..." ; |
| 4940: |
| 4941: std :: string OsStackTraceGetter :: CurrentStackTrace ( int max_depth , int skip_count ) |
| 4942: GTEST_LOCK_EXCLUDED_ ( mutex_ ) { |
| 4943: # if GTEST_HAS_ABSL |
| 4944: std :: string result ; |
| 4945: |
| 4946: if ( max_depth <= 0 ) { |
| 4947: return result ; |
| 4948: } |
| 4949: |
| 4950: max_depth = std :: min ( max_depth , kMaxStackTraceDepth ) ; |
| 4951: |
| 4952: std :: vector < void * > raw_stack ( max_depth ) ; |
| 4953: |
| 4954: const int raw_stack_size = |
| 4955: absl :: GetStackTrace ( & raw_stack [ 0 ] , max_depth , skip_count + 1 ) ; |
| 4956: |
| 4957: void * caller_frame = nullptr ; |
| 4958: { |
| 4959: MutexLock lock ( & mutex_ ) ; |
| 4960: caller_frame = caller_frame_ ; |
| 4961: } |
| 4962: |
| 4963: for ( int i = 0 ; i < raw_stack_size ; ++ i ) { |
| 4964: if ( raw_stack [ i ] == caller_frame && |
| 4965: ! GTEST_FLAG ( show_internal_stack_frames ) ) { |
| 4966: |
| 4967: absl :: StrAppend ( & result , kElidedFramesMarker , "\n" ) ; |
| 4968: break ; |
| 4969: } |
| 4970: |
| 4971: char tmp [ 1024 ] ; |
| 4972: const char * symbol = "(unknown)" ; |
| 4973: if ( absl :: Symbolize ( raw_stack [ i ] , tmp , sizeof ( tmp ) ) ) { |
| 4974: symbol = tmp ; |
| 4975: } |
| 4976: |
| 4977: char line [ 1024 ] ; |
| 4978: snprintf ( line , sizeof ( line ) , " %p: %s\n" , raw_stack [ i ] , symbol ) ; |
| 4979: result += line ; |
| 4980: } |
| 4981: |
| 4982: return result ; |
| 4983: |
| 4984: # else |
| 4985: static_cast < void > ( max_depth ) ; |
| 4986: static_cast < void > ( skip_count ) ; |
| 4987: return "" ; |
| 4988: # endif |
| 4989: } |
| 4990: |
| 4991: void OsStackTraceGetter :: UponLeavingGTest ( ) GTEST_LOCK_EXCLUDED_ ( mutex_ ) { |
| 4992: # if GTEST_HAS_ABSL |
| 4993: void * caller_frame = nullptr ; |
| 4994: if ( absl :: GetStackTrace ( & caller_frame , 1 , 3 ) <= 0 ) { |
| 4995: caller_frame = nullptr ; |
| 4996: } |
| 4997: |
| 4998: MutexLock lock ( & mutex_ ) ; |
| 4999: caller_frame_ = caller_frame ; |
| 5000: # endif |
| 5001: } |
| 5002: |
| 5003: |
| 5004: |
| 5005: class ScopedPrematureExitFile { |
| 5006: public : |
| 5007: explicit ScopedPrematureExitFile ( const char * premature_exit_filepath ) |
| 5008: : premature_exit_filepath_ ( premature_exit_filepath ? |
| 5009: premature_exit_filepath : "" ) {/*
// If a path to the premature-exit file is specified...
if (!premature_exit_filepath_.empty()) {
// create the file with a single "0" character in it. I/O
// errors are ignored as there's nothing better we can do and we
// don't want to fail the test because of this.
FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
fwrite("0", 1, 1, pfile);
fclose(pfile);
}
*/ |
| 5010: |
5011: if/* if (!premature_exit_filepath_.empty()) {
// create the file with a single "0" character in it. I/O
// errors are ignored as there's nothing better we can do and we
// don't want to fail the test because of this.
FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
fwrite("0", 1, 1, pfile);
fclose(pfile);
} */ (truefalse!!premature_exit_filepath_.empty() ! premature_exit_filepath_ . empty ( ) ) {/*
// create the file with a single "0" character in it. I/O
// errors are ignored as there's nothing better we can do and we
// don't want to fail the test because of this.
FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
fwrite("0", 1, 1, pfile);
fclose(pfile);
*/ |
| 5012: |
| 5013: |
| 5014: |
| 5015: FILE * pfile = posix :: FOpen ( premature_exit_filepath , "w" ) ; |
| 5016: fwrite ( "0" , 1 , 1 , pfile ) ; |
| 5017: fclose ( pfile ) ; |
| 5018: } |
| 5019: } |
| 5020: |
| 5021: ~ ScopedPrematureExitFile ( ) {/*
#if !defined GTEST_OS_ESP8266
if (!premature_exit_filepath_.empty()) {
int retval = remove(premature_exit_filepath_.c_str());
if (retval) {
GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
<< premature_exit_filepath_ << "\" with error "
<< retval;
}
}
#endif
*/ |
| 5022: # if ! defined GTEST_OS_ESP8266 |
5023: if/* if (!premature_exit_filepath_.empty()) {
int retval = remove(premature_exit_filepath_.c_str());
if (retval) {
GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
<< premature_exit_filepath_ << "\" with error "
<< retval;
}
} */ (truefalse!!premature_exit_filepath_.empty() ! premature_exit_filepath_ . empty ( ) ) {/*
int retval = remove(premature_exit_filepath_.c_str());
if (retval) {
GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
<< premature_exit_filepath_ << "\" with error "
<< retval;
}
*/ |
| 5024: int retval = remove ( premature_exit_filepath_ . c_str ( ) ) ; |
5025: if/* if (retval) {
GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
<< premature_exit_filepath_ << "\" with error "
<< retval;
} */ retval ) {/*
GTEST_LOG_(ERROR) << "Failed to remove premature exit filepath \""
<< premature_exit_filepath_ << "\" with error "
<< retval;
*/ |
| 5026: GTEST_LOG_ ( ERROR ) << "Failed to remove premature exit filepath \"" |
| 5027: << premature_exit_filepath_ << "\" with error " |
| 5028: << retval ; |
| 5029: } |
| 5030: } |
| 5031: # endif |
| 5032: } |
| 5033: |
| 5034: private : |
| 5035: const std :: string premature_exit_filepath_ ; |
| 5036: |
| 5037: GTEST_DISALLOW_COPY_AND_ASSIGN_ ( ScopedPrematureExitFile ) ; |
| 5038: } ; |
| 5039: |
| 5040: } |
| 5041: |
| 5042: |
| 5043: |
| 5044: TestEventListeners :: TestEventListeners ( ) |
| 5045: : repeater_ ( new internal :: TestEventRepeater ( ) ) , |
| 5046: default_result_printer_ ( nullptr ) , |
| 5047: default_xml_generator_ ( nullptr ) { } |
| 5048: |
| 5049: TestEventListeners :: ~ TestEventListeners ( ) delete repeater_ ; } |
| 5050: |
| 5051: |
| 5052: |
| 5053: |
| 5054: |
| 5055: void TestEventListeners :: Append ( TestEventListener * listener ) {/*
repeater_->Append(listener);
*/ |
5056: repeater_/* repeater_->Append(listener) */ -> Append ( listener ) ; |
| 5057: } |
| 5058: |
| 5059: |
| 5060: |
| 5061: |
| 5062: TestEventListener * TestEventListeners :: Release ( TestEventListener * listener ) { |
5063: if/* if (listener == default_result_printer_)
default_result_printer_ = nullptr;
else if (listener == default_xml_generator_)
default_xml_generator_ = nullptr */ listener == default_result_printer_ ) |
| 5064: default_result_printer_ = nullptr ; |
| 5065: else if/* if (listener == default_xml_generator_)
default_xml_generator_ = nullptr */ listener == default_xml_generator_ ) |
| 5066: default_xml_generator_ = nullptr ; |
| 5067: return repeater_ -> Release ( listener ) ; |
| 5068: } |
| 5069: |
| 5070: |
| 5071: |
| 5072: TestEventListener * TestEventListeners :: repeater ( ) { return repeater_ ; } |
| 5073: |
| 5074: |
| 5075: |
| 5076: |
| 5077: |
| 5078: |
| 5079: void TestEventListeners :: SetDefaultResultPrinter ( TestEventListener * listener ) {/*
if (default_result_printer_ != listener) {
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_result_printer_);
default_result_printer_ = listener;
if (listener != nullptr) Append(listener);
}
*/ |
5080: if/* if (default_result_printer_ != listener) {
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_result_printer_);
default_result_printer_ = listener;
if (listener != nullptr) Append(listener);
} */ default_result_printer_ != listener ) {/*
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_result_printer_);
default_result_printer_ = listener;
if (listener != nullptr) Append(listener);
*/ |
| 5081: |
| 5082: |
| 5083: delete Release ( default_result_printer_ ) ; |
5084: default_result_printer_/* default_result_printer_ = listener */ = listener ; |
5085: if/* if (listener != nullptr) Append(listener) */ listener != nullptr ) Append ( listener ) ; |
| 5086: } |
| 5087: } |
| 5088: |
| 5089: |
| 5090: |
| 5091: |
| 5092: |
| 5093: |
| 5094: void TestEventListeners :: SetDefaultXmlGenerator ( TestEventListener * listener ) {/*
if (default_xml_generator_ != listener) {
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_xml_generator_);
default_xml_generator_ = listener;
if (listener != nullptr) Append(listener);
}
*/ |
5095: if/* if (default_xml_generator_ != listener) {
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_xml_generator_);
default_xml_generator_ = listener;
if (listener != nullptr) Append(listener);
} */ default_xml_generator_ != listener ) {/*
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_xml_generator_);
default_xml_generator_ = listener;
if (listener != nullptr) Append(listener);
*/ |
| 5096: |
| 5097: |
| 5098: delete Release ( default_xml_generator_ ) ; |
5099: default_xml_generator_/* default_xml_generator_ = listener */ = listener ; |
5100: if/* if (listener != nullptr) Append(listener) */ listener != nullptr ) Append ( listener ) ; |
| 5101: } |
| 5102: } |
| 5103: |
| 5104: |
| 5105: |
| 5106: bool TestEventListeners :: EventForwardingEnabled ( ) const { |
| 5107: return -> forwarding_enabled ( ) ; |
| 5108: } |
| 5109: |
| 5110: void TestEventListeners :: SuppressEventForwarding ( ) {/*
repeater_->set_forwarding_enabled(false);
*/ |
5111: repeater_/* repeater_->set_forwarding_enabled(false) */ -> set_forwarding_enabled ( false ) ; |
| 5112: } |
| 5113: |
| 5114: |
| 5115: |
| 5116: |
| 5117: |
| 5118: |
| 5119: |
| 5120: |
| 5121: |
| 5122: |
| 5123: UnitTest * UnitTest :: GetInstance ( ) { |
| 5124: |
| 5125: |
| 5126: |
| 5127: |
| 5128: # if defined ( __BORLANDC__ ) |
| 5129: static UnitTest * const instance = new UnitTest ; |
| 5130: return instance ; |
| 5131: # else |
| 5132: static UnitTest instance ; |
| 5133: return & instance ; |
| 5134: # endif |
| 5135: } |
| 5136: |
| 5137: |
| 5138: int UnitTest :: successful_test_suite_count ( ) const { |
| 5139: return impl ( ) -> successful_test_suite_count ( ) ; |
| 5140: } |
| 5141: |
| 5142: |
| 5143: int UnitTest :: failed_test_suite_count ( ) const { |
| 5144: return impl ( ) -> failed_test_suite_count ( ) ; |
| 5145: } |
| 5146: |
| 5147: |
| 5148: int UnitTest :: total_test_suite_count ( ) const { |
| 5149: return impl ( ) -> total_test_suite_count ( ) ; |
| 5150: } |
| 5151: |
| 5152: |
| 5153: |
| 5154: int UnitTest :: test_suite_to_run_count ( ) const { |
| 5155: return impl ( ) -> test_suite_to_run_count ( ) ; |
| 5156: } |
| 5157: |
| 5158: |
| 5159: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 5160: int UnitTest :: successful_test_case_count ( ) const { |
| 5161: return impl ( ) -> successful_test_suite_count ( ) ; |
| 5162: } |
| 5163: int UnitTest :: failed_test_case_count ( ) const { |
| 5164: return impl ( ) -> failed_test_suite_count ( ) ; |
| 5165: } |
| 5166: int UnitTest :: total_test_case_count ( ) const { |
| 5167: return impl ( ) -> total_test_suite_count ( ) ; |
| 5168: } |
| 5169: int UnitTest :: test_case_to_run_count ( ) const { |
| 5170: return impl ( ) -> test_suite_to_run_count ( ) ; |
| 5171: } |
| 5172: # endif |
| 5173: |
| 5174: |
| 5175: int UnitTest :: successful_test_count ( ) const { |
| 5176: return impl ( ) -> successful_test_count ( ) ; |
| 5177: } |
| 5178: |
| 5179: |
| 5180: int UnitTest :: skipped_test_count ( ) const { |
| 5181: return impl ( ) -> skipped_test_count ( ) ; |
| 5182: } |
| 5183: |
| 5184: |
| 5185: int UnitTest :: failed_test_count ( ) const { return impl ( ) -> failed_test_count ( ) ; } |
| 5186: |
| 5187: |
| 5188: int UnitTest :: reportable_disabled_test_count ( ) const { |
| 5189: return impl ( ) -> reportable_disabled_test_count ( ) ; |
| 5190: } |
| 5191: |
| 5192: |
| 5193: int UnitTest :: disabled_test_count ( ) const { |
| 5194: return impl ( ) -> disabled_test_count ( ) ; |
| 5195: } |
| 5196: |
| 5197: |
| 5198: int UnitTest :: reportable_test_count ( ) const { |
| 5199: return impl ( ) -> reportable_test_count ( ) ; |
| 5200: } |
| 5201: |
| 5202: |
| 5203: int UnitTest :: total_test_count ( ) const { return impl ( ) -> total_test_count ( ) ; } |
| 5204: |
| 5205: |
| 5206: int UnitTest :: test_to_run_count ( ) const { return impl ( ) -> test_to_run_count ( ) ; } |
| 5207: |
| 5208: |
| 5209: |
| 5210: internal :: TimeInMillis UnitTest :: start_timestamp ( ) const { |
| 5211: return impl ( ) -> start_timestamp ( ) ; |
| 5212: } |
| 5213: |
| 5214: |
| 5215: internal :: TimeInMillis UnitTest :: elapsed_time ( ) const { |
| 5216: return impl ( ) -> elapsed_time ( ) ; |
| 5217: } |
| 5218: |
| 5219: |
| 5220: |
| 5221: bool UnitTest :: Passed ( ) const { return ( ) -> Passed ( ) ; } |
| 5222: |
| 5223: |
| 5224: |
| 5225: bool UnitTest :: Failed ( ) const { return ( ) -> Failed ( ) ; } |
| 5226: |
| 5227: |
| 5228: |
| 5229: const TestSuite * UnitTest :: GetTestSuite ( int i ) const { |
| 5230: return impl ( ) -> GetTestSuite ( i ) ; |
| 5231: } |
| 5232: |
| 5233: |
| 5234: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 5235: const TestCase * UnitTest :: GetTestCase ( int i ) const { |
| 5236: return impl ( ) -> GetTestCase ( i ) ; |
| 5237: } |
| 5238: # endif |
| 5239: |
| 5240: |
| 5241: |
| 5242: const TestResult & UnitTest :: ad_hoc_test_result ( ) const { |
| 5243: return * impl ( ) -> ad_hoc_test_result ( ) ; |
| 5244: } |
| 5245: |
| 5246: |
| 5247: |
| 5248: TestSuite * UnitTest :: GetMutableTestSuite ( int i ) { |
| 5249: return impl ( ) -> GetMutableSuiteCase ( i ) ; |
| 5250: } |
| 5251: |
| 5252: |
| 5253: |
| 5254: TestEventListeners & UnitTest :: listeners ( ) { |
| 5255: return * impl ( ) -> listeners ( ) ; |
| 5256: } |
| 5257: |
| 5258: |
| 5259: |
| 5260: |
| 5261: |
| 5262: |
| 5263: |
| 5264: |
| 5265: |
| 5266: |
| 5267: |
| 5268: Environment * UnitTest :: AddEnvironment ( Environment * env ) { |
| 5269: if env == nullptr ) { |
| 5270: return nullptr ; |
| 5271: } |
| 5272: |
5273: impl_/* impl_->environments().push_back(env) */ -> environments ( ) . push_back ( env ) ; |
| 5274: return env ; |
| 5275: } |
| 5276: |
| 5277: |
| 5278: |
| 5279: |
| 5280: |
| 5281: void UnitTest :: AddTestPartResult ( |
| 5282: TestPartResult :: Type result_type , |
| 5283: const char * file_name , |
| 5284: int line_number , |
| 5285: const std :: string & message , |
| 5286: const std :: string & os_stack_trace ) GTEST_LOCK_EXCLUDED_ ( mutex_ ) { |
| 5287: Message msg ; |
| 5288: << message ; |
| 5289: |
| 5290: internal :: MutexLock lock ( & mutex_ ) ; |
5291: if/* if (impl_->gtest_trace_stack().size() > 0) {
msg << "\n" << GTEST_NAME_ << " trace:";
for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
<< " " << trace.message;
}
} */ impl_ -> gtest_trace_stack ( ) . size ( ) > 0 ) {/*
msg << "\n" << GTEST_NAME_ << " trace:";
for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
<< " " << trace.message;
}
*/ |
5292: msg/* msg << "\n" << GTEST_NAME_ << " trace:" */ << "\n" << GTEST_NAME_ << " trace:" ; |
| 5293: |
5294: for/* for (size_t i = impl_->gtest_trace_stack().size(); i > 0; --i) {
const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
<< " " << trace.message;
} */ ( size_t i = impl_ -> gtest_trace_stack ( ) . size ( ) ; i > 0 ; -- i ) {/*
const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
<< " " << trace.message;
*/ |
| 5295: const internal :: TraceInfo & trace = impl_ -> gtest_trace_stack ( ) [ i - 1 ] ; |
| 5296: msg << "\n" << internal :: FormatFileLocation ( trace . file , trace . line ) |
| 5297: << " " << trace . message ; |
| 5298: } |
| 5299: } |
| 5300: |
5301: if/* if (os_stack_trace.c_str() != nullptr && !os_stack_trace.empty()) {
msg << internal::kStackTraceMarker << os_stack_trace;
} */ (truefalsetruefalsetruefalse os_stack_trace . c_str ( ) != nullptr !!!os_stack_trace.empty() os_stack_trace . empty ( ) ) {/*
msg << internal::kStackTraceMarker << os_stack_trace;
*/ |
5302: msg/* msg << internal::kStackTraceMarker << os_stack_trace */ << internal :: kStackTraceMarker << os_stack_trace ; |
| 5303: } |
| 5304: |
| 5305: const TestPartResult result = TestPartResult ( |
| 5306: result_type , file_name , line_number , msg . GetString ( ) . c_str ( ) ) ; |
5307: impl_/* impl_->GetTestPartResultReporterForCurrentThread()->
ReportTestPartResult(result) */ -> GetTestPartResultReporterForCurrentThread ( ) -> |
| 5308: ReportTestPartResult ( result ) ; |
| 5309: |
| 5310: if (truefalsetruefalsetruefalse result_type != TestPartResult :: kSuccess |
| 5311: != TestPartResult :: kSkip ) { |
| 5312: |
| 5313: |
| 5314: |
| 5315: |
| 5316: |
| 5317: if ( GTEST_FLAG ( break_on_failure ) ) { |
| 5318: # if GTEST_OS_WINDOWS && ! GTEST_OS_WINDOWS_PHONE && ! GTEST_OS_WINDOWS_RT |
| 5319: |
| 5320: |
| 5321: |
| 5322: DebugBreak ( ) ; |
| 5323: # elif ( ! defined ( __native_client__ ) ) && |
| 5324: ( ( defined ( __clang__ ) || defined ( __GNUC__ ) ) && |
| 5325: ( defined ( __x86_64__ ) || defined ( __i386__ ) ) ) |
| 5326: |
| 5327: asm ( "int3" ) ; |
| 5328: # else |
| 5329: |
| 5330: |
| 5331: |
| 5332: * static_cast < volatile int * > ( nullptr ) = 1 ; |
| 5333: # endif |
| 5334: } else if ( GTEST_FLAG ( throw_on_failure ) ) { |
| 5335: # if GTEST_HAS_EXCEPTIONS |
| 5336: throw internal :: GoogleTestFailureException ( result ) ; |
| 5337: # else |
| 5338: |
| 5339: |
| 5340: exit ( 1 ) ; |
| 5341: # endif |
| 5342: } |
| 5343: } |
| 5344: } |
| 5345: |
| 5346: |
| 5347: |
| 5348: |
| 5349: |
| 5350: |
| 5351: void UnitTest :: RecordProperty ( const std :: string & key , |
| 5352: const std :: string & value ) {/*
impl_->RecordProperty(TestProperty(key, value));
*/ |
| 5353: impl_ -> RecordProperty ( TestProperty ( key , value ) ) ; |
| 5354: } |
| 5355: |
| 5356: |
| 5357: |
| 5358: |
| 5359: |
| 5360: |
| 5361: int UnitTest :: Run ( ) { |
| 5362: const bool in_death_test_child_process = |
| 5363: :: GTEST_FLAG ( internal_run_death_test ) . length ( ) > 0 ; |
| 5364: |
| 5365: |
| 5366: |
| 5367: |
| 5368: |
| 5369: |
| 5370: |
| 5371: |
| 5372: |
| 5373: |
| 5374: |
| 5375: |
| 5376: |
| 5377: |
| 5378: |
| 5379: |
| 5380: |
| 5381: |
| 5382: |
| 5383: |
| 5384: |
| 5385: |
| 5386: const internal :: ScopedPrematureExitFile premature_exit_file ( |
| 5387: in_death_test_child_process |
| 5388: ? nullptr |
| 5389: : internal :: posix :: GetEnv ( "TEST_PREMATURE_EXIT_FILE" ) ) ; |
| 5390: |
| 5391: |
| 5392: |
5393: impl/* impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions)) */ ( ) -> set_catch_exceptions ( GTEST_FLAG ( catch_exceptions ) ) ; |
| 5394: |
| 5395: # if GTEST_OS_WINDOWS |
| 5396: |
| 5397: |
| 5398: |
| 5399: |
| 5400: if ( impl ( ) -> catch_exceptions ( ) || in_death_test_child_process ) { |
| 5401: # if ! GTEST_OS_WINDOWS_MOBILE && ! GTEST_OS_WINDOWS_PHONE && ! GTEST_OS_WINDOWS_RT |
| 5402: |
| 5403: SetErrorMode ( SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | |
| 5404: SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX ) ; |
| 5405: # endif |
| 5406: |
| 5407: # if ( defined ( _MSC_VER ) || GTEST_OS_WINDOWS_MINGW ) && ! GTEST_OS_WINDOWS_MOBILE |
| 5408: |
| 5409: |
| 5410: |
| 5411: _set_error_mode ( _OUT_TO_STDERR ) ; |
| 5412: # endif |
| 5413: |
| 5414: # if defined ( _MSC_VER ) && ! GTEST_OS_WINDOWS_MOBILE |
| 5415: |
| 5416: |
| 5417: |
| 5418: |
| 5419: |
| 5420: if ( ! GTEST_FLAG ( break_on_failure ) ) |
| 5421: _set_abort_behavior ( |
| 5422: 0x0 , |
| 5423: _WRITE_ABORT_MSG | _CALL_REPORTFAULT ) ; |
| 5424: |
| 5425: |
| 5426: |
| 5427: |
| 5428: |
| 5429: if ( ! IsDebuggerPresent ( ) ) { |
| 5430: ( void ) _CrtSetReportMode ( _CRT_ASSERT , |
| 5431: _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG ) ; |
| 5432: ( void ) _CrtSetReportFile ( _CRT_ASSERT , _CRTDBG_FILE_STDERR ) ; |
| 5433: } |
| 5434: # endif |
| 5435: } |
| 5436: # endif |
| 5437: |
| 5438: return internal :: HandleExceptionsInMethodIfSupported ( |
| 5439: impl ( ) , |
| 5440: & internal :: UnitTestImpl :: RunAllTests , |
| 5441: "auxiliary test code (environments or event listeners)" ) ? 0 : 1 ; |
| 5442: } |
| 5443: |
| 5444: |
| 5445: |
| 5446: const char * UnitTest :: original_working_dir ( ) const { |
| 5447: return impl_ -> original_working_dir_ . c_str ( ) ; |
| 5448: } |
| 5449: |
| 5450: |
| 5451: |
| 5452: const TestSuite * UnitTest :: current_test_suite ( ) const |
| 5453: GTEST_LOCK_EXCLUDED_ ( mutex_ ) { |
| 5454: internal :: MutexLock lock ( & mutex_ ) ; |
| 5455: return impl_ -> current_test_suite ( ) ; |
| 5456: } |
| 5457: |
| 5458: |
| 5459: # ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_ |
| 5460: const TestCase * UnitTest :: current_test_case ( ) const |
| 5461: GTEST_LOCK_EXCLUDED_ ( mutex_ ) { |
| 5462: internal :: MutexLock lock ( & mutex_ ) ; |
| 5463: return impl_ -> current_test_suite ( ) ; |
| 5464: } |
| 5465: # endif |
| 5466: |
| 5467: |
| 5468: |
| 5469: const TestInfo * UnitTest :: current_test_info ( ) const |
| 5470: GTEST_LOCK_EXCLUDED_ ( mutex_ ) { |
| 5471: internal :: MutexLock lock ( & mutex_ ) ; |
| 5472: return impl_ -> current_test_info ( ) ; |
| 5473: } |
| 5474: |
| 5475: |
| 5476: int UnitTest :: random_seed ( ) const { return impl_ -> random_seed ( ) ; } |
| 5477: |
| 5478: |
| 5479: |
| 5480: internal :: ParameterizedTestSuiteRegistry & |
| 5481: UnitTest :: parameterized_test_registry ( ) GTEST_LOCK_EXCLUDED_ ( mutex_ ) { |
| 5482: return impl_ -> parameterized_test_registry ( ) ; |
| 5483: } |
| 5484: |
| 5485: |
| 5486: UnitTest :: UnitTest ( ) {/*
impl_ = new internal::UnitTestImpl(this);
*/ |
5487: impl_/* impl_ = new internal::UnitTestImpl(this) */ = new internal :: UnitTestImpl ( this ) ; |
| 5488: } |
| 5489: |
| 5490: |
| 5491: UnitTest :: ~ UnitTest ( ) |
| 5492: delete impl_ ; |
| 5493: } |
| 5494: |
| 5495: |
| 5496: |
| 5497: void UnitTest :: PushGTestTrace ( const internal :: TraceInfo & trace ) |
| 5498: GTEST_LOCK_EXCLUDED_ ( mutex_ ) {/*
internal::MutexLock lock(&mutex_);
impl_->gtest_trace_stack().push_back(trace);
*/ |
| 5499: internal :: MutexLock lock ( & mutex_ ) ; |
5500: impl_/* impl_->gtest_trace_stack().push_back(trace) */ -> gtest_trace_stack ( ) . push_back ( trace ) ; |
| 5501: } |
| 5502: |
| 5503: |
| 5504: void UnitTest :: PopGTestTrace ( ) |
| 5505: GTEST_LOCK_EXCLUDED_ ( mutex_ ) {/*
internal::MutexLock lock(&mutex_);
impl_->gtest_trace_stack().pop_back();
*/ |
| 5506: internal :: MutexLock lock ( & mutex_ ) ; |
5507: impl_/* impl_->gtest_trace_stack().pop_back() */ -> gtest_trace_stack ( ) . pop_back ( ) ; |
| 5508: } |
| 5509: |
| 5510: namespace internal { |
| 5511: |
| 5512: UnitTestImpl :: UnitTestImpl ( UnitTest * parent ) |
| 5513: : parent_ ( parent ) , |
| 5514: GTEST_DISABLE_MSC_WARNINGS_PUSH_ ( 4355 ) |
| 5515: default_global_test_part_result_reporter_ ( this ) , |
| 5516: default_per_thread_test_part_result_reporter_ ( this ) , |
| 5517: GTEST_DISABLE_MSC_WARNINGS_POP_ ( ) global_test_part_result_repoter_ ( |
| 5518: & default_global_test_part_result_reporter_ ) , |
| 5519: per_thread_test_part_result_reporter_ ( |
| 5520: & default_per_thread_test_part_result_reporter_ ) , |
| 5521: parameterized_test_registry_ ( ) , |
| 5522: parameterized_tests_registered_ ( false ) , |
| 5523: last_death_test_suite_ ( - 1 ) , |
| 5524: current_test_suite_ ( nullptr ) , |
| 5525: current_test_info_ ( nullptr ) , |
| 5526: ad_hoc_test_result_ ( ) , |
| 5527: os_stack_trace_getter_ ( nullptr ) , |
| 5528: post_flag_parse_init_performed_ ( false ) , |
| 5529: random_seed_ ( 0 ) , |
| 5530: random_ ( 0 ) , |
| 5531: start_timestamp_ ( 0 ) , |
| 5532: elapsed_time_ ( 0 ) , |
| 5533: # if GTEST_HAS_DEATH_TEST |
| 5534: death_test_factory_ ( new DefaultDeathTestFactory ) , |
| 5535: # endif |
| 5536: |
| 5537: catch_exceptions_ ( false ) {/*
listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);
*/ |
| 5538: listeners ( ) -> SetDefaultResultPrinter ( new PrettyUnitTestResultPrinter ) ; |
| 5539: } |
| 5540: |
| 5541: UnitTestImpl :: ~ UnitTestImpl ( ) {/*
// Deletes every TestSuite.
ForEach(test_suites_, internal::Delete<TestSuite>);
// Deletes every Environment.
ForEach(environments_, internal::Delete<Environment>);
delete os_stack_trace_getter_;
*/ |
| 5542: |
| 5543: ForEach ( test_suites_ , internal :: Delete < TestSuite > ) ; |
| 5544: |
| 5545: |
| 5546: ForEach ( environments_ , internal :: Delete < Environment > ) ; |
| 5547: |
| 5548: delete os_stack_trace_getter_ ; |
| 5549: } |
| 5550: |
| 5551: |
| 5552: |
| 5553: |
| 5554: |
| 5555: |
| 5556: void UnitTestImpl :: RecordProperty ( const TestProperty & test_property ) {/*
std::string xml_element;
TestResult* test_result; // TestResult appropriate for property recording.
if (current_test_info_ != nullptr) {
xml_element = "testcase";
test_result = &(current_test_info_->result_);
} else if (current_test_suite_ != nullptr) {
xml_element = "testsuite";
test_result = &(current_test_suite_->ad_hoc_test_result_);
} else {
xml_element = "testsuites";
test_result = &ad_hoc_test_result_;
}
test_result->RecordProperty(xml_element, test_property);
*/ |
| 5557: std :: string xml_element ; |
| 5558: TestResult * test_result ; |
| 5559: |
5560: if/* if (current_test_info_ != nullptr) {
xml_element = "testcase";
test_result = &(current_test_info_->result_);
} else if (current_test_suite_ != nullptr) {
xml_element = "testsuite";
test_result = &(current_test_suite_->ad_hoc_test_result_);
} else {
xml_element = "testsuites";
test_result = &ad_hoc_test_result_;
} */ current_test_info_ != nullptr ) {/*
xml_element = "testcase";
test_result = &(current_test_info_->result_);
*/ |
5561: xml_element/* xml_element = "testcase" */ = "testcase" ; |
5562: test_result/* test_result = &(current_test_info_->result_) */ = & ( current_test_info_ -> result_ ) ; |
| 5563: } else if/* if (current_test_suite_ != nullptr) {
xml_element = "testsuite";
test_result = &(current_test_suite_->ad_hoc_test_result_);
} else {
xml_element = "testsuites";
test_result = &ad_hoc_test_result_;
} */ current_test_suite_ != nullptr ) {/*
xml_element = "testsuite";
test_result = &(current_test_suite_->ad_hoc_test_result_);
*/ |
5564: xml_element/* xml_element = "testsuite" */ = "testsuite" ; |
5565: test_result/* test_result = &(current_test_suite_->ad_hoc_test_result_) */ = & ( current_test_suite_ -> ad_hoc_test_result_ ) ; |
| 5566: } else {/*
xml_element = "testsuites";
test_result = &ad_hoc_test_result_;
*/ |
5567: xml_element/* xml_element = "testsuites" */ = "testsuites" ; |
5568: test_result/* test_result = &ad_hoc_test_result_ */ = & ad_hoc_test_result_ ; |
| 5569: } |
5570: test_result/* test_result->RecordProperty(xml_element, test_property) */ -> RecordProperty ( xml_element , test_property ) ; |
| 5571: } |
| 5572: |
| 5573: # if GTEST_HAS_DEATH_TEST |
| 5574: |
| 5575: |
| 5576: void UnitTestImpl :: SuppressTestEventsIfInSubprocess ( ) {/*
if (internal_run_death_test_flag_.get() != nullptr)
listeners()->SuppressEventForwarding();
*/ |
5577: if/* if (internal_run_death_test_flag_.get() != nullptr)
listeners()->SuppressEventForwarding() */ internal_run_death_test_flag_ . get ( ) != nullptr ) |
| 5578: listeners ( ) -> SuppressEventForwarding ( ) ; |
| 5579: } |
| 5580: # endif |
| 5581: |
| 5582: |
| 5583: |
| 5584: void UnitTestImpl :: ConfigureXmlOutput ( ) {/*
const std::string& output_format = UnitTestOptions::GetOutputFormat();
if (output_format == "xml") {
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format == "json") {
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format << "\" ignored.";
}
*/ |
| 5585: const std :: string & output_format = UnitTestOptions :: GetOutputFormat ( ) ; |
5586: if/* if (output_format == "xml") {
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format == "json") {
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format << "\" ignored.";
} */ output_format == "xml" ) {/*
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
*/ |
| 5587: listeners ( ) -> SetDefaultXmlGenerator ( new XmlUnitTestResultPrinter ( |
| 5588: UnitTestOptions :: GetAbsolutePathToOutputFile ( ) . c_str ( ) ) ) ; |
| 5589: } else if/* if (output_format == "json") {
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format << "\" ignored.";
} */ output_format == "json" ) {/*
listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
*/ |
| 5590: listeners ( ) -> SetDefaultXmlGenerator ( new JsonUnitTestResultPrinter ( |
| 5591: UnitTestOptions :: GetAbsolutePathToOutputFile ( ) . c_str ( ) ) ) ; |
| 5592: } else if/* if (output_format != "") {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format << "\" ignored.";
} */ output_format != "" ) {/*
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format << "\" ignored.";
*/ |
| 5593: GTEST_LOG_ ( WARNING ) << "WARNING: unrecognized output format \"" |
| 5594: << output_format << "\" ignored." ; |
| 5595: } |
| 5596: } |
| 5597: |
| 5598: # if GTEST_CAN_STREAM_RESULTS_ |
| 5599: |
| 5600: |
| 5601: void UnitTestImpl :: ConfigureStreamingOutput ( ) {/*
const std::string& target = GTEST_FLAG(stream_result_to);
if (!target.empty()) {
const size_t pos = target.find(':');
if (pos != std::string::npos) {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
<< "\" ignored.";
}
}
*/ |
| 5602: const std :: string & target = GTEST_FLAG ( stream_result_to ) ; |
5603: if/* if (!target.empty()) {
const size_t pos = target.find(':');
if (pos != std::string::npos) {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
<< "\" ignored.";
}
} */ (truefalse!!target.empty() ! target . empty ( ) ) {/*
const size_t pos = target.find(':');
if (pos != std::string::npos) {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
<< "\" ignored.";
}
*/ |
| 5604: const size_t pos = target . find ( ':' ) ; |
5605: if/* if (pos != std::string::npos) {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
<< "\" ignored.";
} */ pos != std :: string :: npos ) {/*
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
*/ |
| 5606: listeners ( ) -> Append ( new StreamingListener ( target . substr ( 0 , pos ) , |
| 5607: target . substr ( pos + 1 ) ) ) ; |
| 5608: } else {/*
GTEST_LOG_(WARNING) << "unrecognized streaming target \"" << target
<< "\" ignored.";
*/ |
| 5609: GTEST_LOG_ ( WARNING ) << "unrecognized streaming target \"" << target |
| 5610: << "\" ignored." ; |
| 5611: } |
| 5612: } |
| 5613: } |
| 5614: # endif |
| 5615: |
| 5616: |
| 5617: |
| 5618: |
| 5619: |
| 5620: |
| 5621: void UnitTestImpl :: PostFlagParsingInit ( ) {/*
// Ensures that this function does not execute more than once.
if (!post_flag_parse_init_performed_) {
post_flag_parse_init_performed_ = true;
#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
// Register to send notifications about key process state changes.
listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());
#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
#if GTEST_HAS_DEATH_TEST
InitDeathTestSubprocessControlInfo();
SuppressTestEventsIfInSubprocess();
#endif // GTEST_HAS_DEATH_TEST
// Registers parameterized tests. This makes parameterized tests
// available to the UnitTest reflection API without running
// RUN_ALL_TESTS.
RegisterParameterizedTests();
// Configures listeners for XML output. This makes it possible for users
// to shut down the default XML output before invoking RUN_ALL_TESTS.
ConfigureXmlOutput();
if (GTEST_FLAG(brief)) {
listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
}
#if GTEST_CAN_STREAM_RESULTS_
// Configures listeners for streaming test results to the specified server.
ConfigureStreamingOutput();
#endif // GTEST_CAN_STREAM_RESULTS_
#if GTEST_HAS_ABSL
if (GTEST_FLAG(install_failure_signal_handler)) {
absl::FailureSignalHandlerOptions options;
absl::InstallFailureSignalHandler(options);
}
#endif // GTEST_HAS_ABSL
}
*/ |
| 5622: |
5623: if/* if (!post_flag_parse_init_performed_) {
post_flag_parse_init_performed_ = true;
#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
// Register to send notifications about key process state changes.
listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());
#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
#if GTEST_HAS_DEATH_TEST
InitDeathTestSubprocessControlInfo();
SuppressTestEventsIfInSubprocess();
#endif // GTEST_HAS_DEATH_TEST
// Registers parameterized tests. This makes parameterized tests
// available to the UnitTest reflection API without running
// RUN_ALL_TESTS.
RegisterParameterizedTests();
// Configures listeners for XML output. This makes it possible for users
// to shut down the default XML output before invoking RUN_ALL_TESTS.
ConfigureXmlOutput();
if (GTEST_FLAG(brief)) {
listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
}
#if GTEST_CAN_STREAM_RESULTS_
// Configures listeners for streaming test results to the specified server.
ConfigureStreamingOutput();
#endif // GTEST_CAN_STREAM_RESULTS_
#if GTEST_HAS_ABSL
if (GTEST_FLAG(install_failure_signal_handler)) {
absl::FailureSignalHandlerOptions options;
absl::InstallFailureSignalHandler(options);
}
#endif // GTEST_HAS_ABSL
} */ (truefalse!!post_flag_parse_init_performed_ ! post_flag_parse_init_performed_ ) {/*
post_flag_parse_init_performed_ = true;
#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
// Register to send notifications about key process state changes.
listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());
#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
#if GTEST_HAS_DEATH_TEST
InitDeathTestSubprocessControlInfo();
SuppressTestEventsIfInSubprocess();
#endif // GTEST_HAS_DEATH_TEST
// Registers parameterized tests. This makes parameterized tests
// available to the UnitTest reflection API without running
// RUN_ALL_TESTS.
RegisterParameterizedTests();
// Configures listeners for XML output. This makes it possible for users
// to shut down the default XML output before invoking RUN_ALL_TESTS.
ConfigureXmlOutput();
if (GTEST_FLAG(brief)) {
listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
}
#if GTEST_CAN_STREAM_RESULTS_
// Configures listeners for streaming test results to the specified server.
ConfigureStreamingOutput();
#endif // GTEST_CAN_STREAM_RESULTS_
#if GTEST_HAS_ABSL
if (GTEST_FLAG(install_failure_signal_handler)) {
absl::FailureSignalHandlerOptions options;
absl::InstallFailureSignalHandler(options);
}
#endif // GTEST_HAS_ABSL
*/ |
5624: post_flag_parse_init_performed_/* post_flag_parse_init_performed_ = true */ = true ; |
| 5625: |
| 5626: # if defined ( GTEST_CUSTOM_TEST_EVENT_LISTENER_ ) |
| 5627: |
| 5628: listeners ( ) -> Append ( new GTEST_CUSTOM_TEST_EVENT_LISTENER_ ( ) ) ; |
| 5629: # endif |
| 5630: |
| 5631: # if GTEST_HAS_DEATH_TEST |
5632: InitDeathTestSubprocessControlInfo/* InitDeathTestSubprocessControlInfo() */ ( ) ; |
5633: SuppressTestEventsIfInSubprocess/* SuppressTestEventsIfInSubprocess() */ ( ) ; |
| 5634: # endif |
| 5635: |
| 5636: |
| 5637: |
| 5638: |
5639: RegisterParameterizedTests/* RegisterParameterizedTests() */ ( ) ; |
| 5640: |
| 5641: |
| 5642: |
5643: ConfigureXmlOutput/* ConfigureXmlOutput() */ ( ) ; |
| 5644: |
5645: if/* if (GTEST_FLAG(brief)) {
listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
} */ ( GTEST_FLAG ( brief ) ) {/*
listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter);
*/ |
5646: listeners/* listeners()->SetDefaultResultPrinter(new BriefUnitTestResultPrinter) */ ( ) -> SetDefaultResultPrinter ( new BriefUnitTestResultPrinter ) ; |
| 5647: } |
| 5648: |
| 5649: # if GTEST_CAN_STREAM_RESULTS_ |
| 5650: |
5651: ConfigureStreamingOutput/* ConfigureStreamingOutput() */ ( ) ; |
| 5652: # endif |
| 5653: |
| 5654: # if GTEST_HAS_ABSL |
| 5655: if ( GTEST_FLAG ( install_failure_signal_handler ) ) { |
| 5656: absl :: FailureSignalHandlerOptions options ; |
| 5657: absl :: InstallFailureSignalHandler ( options ) ; |
| 5658: } |
| 5659: # endif |
| 5660: } |
| 5661: } |
| 5662: |
| 5663: |
| 5664: |
| 5665: |
| 5666: |
| 5667: |
| 5668: |
| 5669: |
| 5670: |
| 5671: class TestSuiteNameIs { |
| 5672: public : |
| 5673: |
| 5674: explicit TestSuiteNameIs ( const std :: string & name ) : name_ ( name ) { } |
| 5675: |
| 5676: |
| 5677: bool operator ( ) ( const TestSuite * test_suite ) const { |
| 5678: return test_suitetruefalsetruefalsetruefalse != nullptr |
| 5679: ( test_suite -> name ( ) , name_ . c_str ( ) ) == 0 ; |
| 5680: } |
| 5681: |
| 5682: private : |
| 5683: std :: string name_ ; |
| 5684: } ; |
| 5685: |
| 5686: |
| 5687: |
| 5688: |
| 5689: |
| 5690: |
| 5691: |
| 5692: |
| 5693: |
| 5694: |
| 5695: |
| 5696: |
| 5697: |
| 5698: TestSuite * UnitTestImpl :: GetTestSuite ( |
| 5699: const char * test_suite_name , const char * type_param , |
| 5700: internal :: SetUpTestSuiteFunc set_up_tc , |
| 5701: internal :: TearDownTestSuiteFunc tear_down_tc ) { |
| 5702: |
| 5703: const auto test_suite = |
| 5704: std :: find_if ( test_suites_ . rbegin ( ) , test_suites_ . rend ( ) , |
| 5705: TestSuiteNameIs ( test_suite_name ) ) ; |
| 5706: |
| 5707: if test_suite != test_suites_ . rend ( ) ) return * test_suite ; |
| 5708: |
| 5709: |
| 5710: auto * const new_test_suite = |
| 5711: new TestSuite ( test_suite_name , type_param , set_up_tc , tear_down_tc ) ; |
| 5712: |
| 5713: |
5714: if/* if (internal::UnitTestOptions::MatchesFilter(test_suite_name,
kDeathTestSuiteFilter)) {
// Yes. Inserts the test suite after the last death test suite
// defined so far. This only works when the test suites haven't
// been shuffled. Otherwise we may end up running a death test
// after a non-death test.
++last_death_test_suite_;
test_suites_.insert(test_suites_.begin() + last_death_test_suite_,
new_test_suite);
} else {
// No. Appends to the end of the list.
test_suites_.push_back(new_test_suite);
} */ internal :: UnitTestOptions :: MatchesFilter ( test_suite_name , |
| 5715: kDeathTestSuiteFilter ) ) {/*
// Yes. Inserts the test suite after the last death test suite
// defined so far. This only works when the test suites haven't
// been shuffled. Otherwise we may end up running a death test
// after a non-death test.
++last_death_test_suite_;
test_suites_.insert(test_suites_.begin() + last_death_test_suite_,
new_test_suite);
*/ |
| 5716: |
| 5717: |
| 5718: |
| 5719: |
5720: ++/* ++last_death_test_suite_ */ last_death_test_suite_ ; |
| 5721: test_suites_ . insert ( test_suites_ . begin ( ) + last_death_test_suite_ , |
| 5722: new_test_suite ) ; |
| 5723: } else {/*
// No. Appends to the end of the list.
test_suites_.push_back(new_test_suite);
*/ |
| 5724: |
5725: test_suites_/* test_suites_.push_back(new_test_suite) */ . push_back ( new_test_suite ) ; |
| 5726: } |
| 5727: |
| 5728: test_suite_indices_ . push_back ( static_cast < int > ( test_suite_indices_ . size ( ) ) ) ; |
| 5729: return new_test_suite ; |
| 5730: } |
| 5731: |
| 5732: |
| 5733: |
| 5734: static void SetUpEnvironment ( Environment * env ) -> SetUp ( ) ; } |
| 5735: static void TearDownEnvironment ( Environment * env ) -> TearDown ( ) ; } |
| 5736: |
| 5737: |
| 5738: |
| 5739: |
| 5740: |
| 5741: |
| 5742: |
| 5743: |
| 5744: |
| 5745: |
| 5746: bool UnitTestImpl :: RunAllTests ( ) { |
| 5747: |
| 5748: |
| 5749: const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized ( ) ; |
| 5750: |
| 5751: |
| 5752: if g_help_flag ) |
| 5753: return ; |
| 5754: |
| 5755: |
| 5756: |
5757: PostFlagParsingInit/* PostFlagParsingInit() */ ( ) ; |
| 5758: |
| 5759: |
| 5760: |
| 5761: |
5762: internal/* internal::WriteToShardStatusFileIfNeeded() */ :: WriteToShardStatusFileIfNeeded ( ) ; |
| 5763: |
| 5764: |
| 5765: |
| 5766: bool in_subprocess_for_death_test = false ; |
| 5767: |
| 5768: # if GTEST_HAS_DEATH_TEST |
5769: in_subprocess_for_death_test/* in_subprocess_for_death_test =
(internal_run_death_test_flag_.get() != nullptr) */ = |
| 5770: internal_run_death_test_flag_ . get ( ) != nullptr ) ; |
| 5771: # if defined ( GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_ ) |
| 5772: if ( in_subprocess_for_death_test ) { |
| 5773: GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_ ( ) ; |
| 5774: } |
| 5775: # endif |
| 5776: # endif |
| 5777: |
| 5778: const bool should_shard = ShouldShard ( kTestTotalShards , kTestShardIndex , |
| 5779: in_subprocess_for_death_test ) ; |
| 5780: |
| 5781: |
| 5782: |
| 5783: const bool has_tests_to_run = ( should_shard |
| 5784: ? HONOR_SHARDING_PROTOCOL |
| 5785: : IGNORE_SHARDING_PROTOCOL ) > 0 ; |
| 5786: |
| 5787: |
| 5788: if ( GTEST_FLAG ( list_tests ) ) { |
| 5789: |
5790: ListTestsMatchingFilter/* ListTestsMatchingFilter() */ ( ) ; |
| 5791: return ; |
| 5792: } |
| 5793: |
5794: random_seed_/* random_seed_ = GTEST_FLAG(shuffle) ?
GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0 */ = GTEST_FLAG ( shuffle ) ? |
| 5795: GetRandomSeedFromFlag ( GTEST_FLAG ( random_seed ) ) : 0 ; |
| 5796: |
| 5797: |
| 5798: bool failed = false ; |
| 5799: |
| 5800: TestEventListener * repeater = listeners ( ) -> repeater ( ) ; |
| 5801: |
5802: start_timestamp_/* start_timestamp_ = GetTimeInMillis() */ = GetTimeInMillis ( ) ; |
5803: repeater/* repeater->OnTestProgramStart(*parent_) */ -> OnTestProgramStart ( * parent_ ) ; |
| 5804: |
| 5805: |
| 5806: |
| 5807: const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG ( repeat ) ; |
| 5808: |
| 5809: const bool gtest_repeat_forever = < 0 ; |
5810: for/* for (int i = 0; gtest_repeat_forever || i != repeat; i++) {
// We want to preserve failures generated by ad-hoc test
// assertions executed before RUN_ALL_TESTS().
ClearNonAdHocTestResult();
Timer timer;
// Shuffles test suites and tests if requested.
if (has_tests_to_run && GTEST_FLAG(shuffle)) {
random()->Reseed(static_cast<uint32_t>(random_seed_));
// This should be done before calling OnTestIterationStart(),
// such that a test event listener can see the actual test order
// in the event.
ShuffleTests();
}
// Tells the unit test event listeners that the tests are about to start.
repeater->OnTestIterationStart(*parent_, i);
// Runs each test suite if there is at least one test to run.
if (has_tests_to_run) {
// Sets up all environments beforehand.
repeater->OnEnvironmentsSetUpStart(*parent_);
ForEach(environments_, SetUpEnvironment);
repeater->OnEnvironmentsSetUpEnd(*parent_);
// Runs the tests only if there was no fatal failure or skip triggered
// during global set-up.
if (Test::IsSkipped()) {
// Emit diagnostics when global set-up calls skip, as it will not be
// emitted by default.
TestResult& test_result =
*internal::GetUnitTestImpl()->current_test_result();
for (int j = 0; j < test_result.total_part_count(); ++j) {
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
}
fflush(stdout);
} else if (!Test::HasFatalFailure()) {
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
}
} else if (Test::HasFatalFailure()) {
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
}
// Tears down all environments in reverse order afterwards.
repeater->OnEnvironmentsTearDownStart(*parent_);
std::for_each(environments_.rbegin(), environments_.rend(),
TearDownEnvironment);
repeater->OnEnvironmentsTearDownEnd(*parent_);
}
elapsed_time_ = timer.Elapsed();
// Tells the unit test event listener that the tests have just finished.
repeater->OnTestIterationEnd(*parent_, i);
// Gets the result and clears it.
if (!Passed()) {
failed = true;
}
// Restores the original test order after the iteration. This
// allows the user to quickly repro a failure that happens in the
// N-th iteration without repeating the first (N - 1) iterations.
// This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
// case the user somehow changes the value of the flag somewhere
// (it's always safe to unshuffle the tests).
UnshuffleTests();
if (GTEST_FLAG(shuffle)) {
// Picks a new random seed for each iteration.
random_seed_ = GetNextRandomSeed(random_seed_);
}
} */ ( int i = 0 ; gtest_repeat_forever || i != repeat ; i ++ ) {/*
// We want to preserve failures generated by ad-hoc test
// assertions executed before RUN_ALL_TESTS().
ClearNonAdHocTestResult();
Timer timer;
// Shuffles test suites and tests if requested.
if (has_tests_to_run && GTEST_FLAG(shuffle)) {
random()->Reseed(static_cast<uint32_t>(random_seed_));
// This should be done before calling OnTestIterationStart(),
// such that a test event listener can see the actual test order
// in the event.
ShuffleTests();
}
// Tells the unit test event listeners that the tests are about to start.
repeater->OnTestIterationStart(*parent_, i);
// Runs each test suite if there is at least one test to run.
if (has_tests_to_run) {
// Sets up all environments beforehand.
repeater->OnEnvironmentsSetUpStart(*parent_);
ForEach(environments_, SetUpEnvironment);
repeater->OnEnvironmentsSetUpEnd(*parent_);
// Runs the tests only if there was no fatal failure or skip triggered
// during global set-up.
if (Test::IsSkipped()) {
// Emit diagnostics when global set-up calls skip, as it will not be
// emitted by default.
TestResult& test_result =
*internal::GetUnitTestImpl()->current_test_result();
for (int j = 0; j < test_result.total_part_count(); ++j) {
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
}
fflush(stdout);
} else if (!Test::HasFatalFailure()) {
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
}
} else if (Test::HasFatalFailure()) {
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
}
// Tears down all environments in reverse order afterwards.
repeater->OnEnvironmentsTearDownStart(*parent_);
std::for_each(environments_.rbegin(), environments_.rend(),
TearDownEnvironment);
repeater->OnEnvironmentsTearDownEnd(*parent_);
}
elapsed_time_ = timer.Elapsed();
// Tells the unit test event listener that the tests have just finished.
repeater->OnTestIterationEnd(*parent_, i);
// Gets the result and clears it.
if (!Passed()) {
failed = true;
}
// Restores the original test order after the iteration. This
// allows the user to quickly repro a failure that happens in the
// N-th iteration without repeating the first (N - 1) iterations.
// This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
// case the user somehow changes the value of the flag somewhere
// (it's always safe to unshuffle the tests).
UnshuffleTests();
if (GTEST_FLAG(shuffle)) {
// Picks a new random seed for each iteration.
random_seed_ = GetNextRandomSeed(random_seed_);
}
*/ |
| 5811: |
| 5812: |
5813: ClearNonAdHocTestResult/* ClearNonAdHocTestResult() */ ( ) ; |
| 5814: |
| 5815: Timer timer ; |
| 5816: |
| 5817: |
5818: if/* if (has_tests_to_run && GTEST_FLAG(shuffle)) {
random()->Reseed(static_cast<uint32_t>(random_seed_));
// This should be done before calling OnTestIterationStart(),
// such that a test event listener can see the actual test order
// in the event.
ShuffleTests();
} */ has_tests_to_run GTEST_FLAG ( shuffle ) ) {/*
random()->Reseed(static_cast<uint32_t>(random_seed_));
// This should be done before calling OnTestIterationStart(),
// such that a test event listener can see the actual test order
// in the event.
ShuffleTests();
*/ |
5819: random/* random()->Reseed(static_cast<uint32_t>(random_seed_)) */ ( ) -> Reseed ( static_cast < uint32_t > ( random_seed_ ) ) ; |
| 5820: |
| 5821: |
| 5822: |
5823: ShuffleTests/* ShuffleTests() */ ( ) ; |
| 5824: } |
| 5825: |
| 5826: |
5827: repeater/* repeater->OnTestIterationStart(*parent_, i) */ -> OnTestIterationStart ( * parent_ , i ) ; |
| 5828: |
| 5829: |
5830: if/* if (has_tests_to_run) {
// Sets up all environments beforehand.
repeater->OnEnvironmentsSetUpStart(*parent_);
ForEach(environments_, SetUpEnvironment);
repeater->OnEnvironmentsSetUpEnd(*parent_);
// Runs the tests only if there was no fatal failure or skip triggered
// during global set-up.
if (Test::IsSkipped()) {
// Emit diagnostics when global set-up calls skip, as it will not be
// emitted by default.
TestResult& test_result =
*internal::GetUnitTestImpl()->current_test_result();
for (int j = 0; j < test_result.total_part_count(); ++j) {
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
}
fflush(stdout);
} else if (!Test::HasFatalFailure()) {
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
}
} else if (Test::HasFatalFailure()) {
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
}
// Tears down all environments in reverse order afterwards.
repeater->OnEnvironmentsTearDownStart(*parent_);
std::for_each(environments_.rbegin(), environments_.rend(),
TearDownEnvironment);
repeater->OnEnvironmentsTearDownEnd(*parent_);
} */ has_tests_to_run ) {/*
// Sets up all environments beforehand.
repeater->OnEnvironmentsSetUpStart(*parent_);
ForEach(environments_, SetUpEnvironment);
repeater->OnEnvironmentsSetUpEnd(*parent_);
// Runs the tests only if there was no fatal failure or skip triggered
// during global set-up.
if (Test::IsSkipped()) {
// Emit diagnostics when global set-up calls skip, as it will not be
// emitted by default.
TestResult& test_result =
*internal::GetUnitTestImpl()->current_test_result();
for (int j = 0; j < test_result.total_part_count(); ++j) {
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
}
fflush(stdout);
} else if (!Test::HasFatalFailure()) {
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
}
} else if (Test::HasFatalFailure()) {
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
}
// Tears down all environments in reverse order afterwards.
repeater->OnEnvironmentsTearDownStart(*parent_);
std::for_each(environments_.rbegin(), environments_.rend(),
TearDownEnvironment);
repeater->OnEnvironmentsTearDownEnd(*parent_);
*/ |
| 5831: |
5832: repeater/* repeater->OnEnvironmentsSetUpStart(*parent_) */ -> OnEnvironmentsSetUpStart ( * parent_ ) ; |
5833: ForEach/* ForEach(environments_, SetUpEnvironment) */ ( environments_ , SetUpEnvironment ) ; |
5834: repeater/* repeater->OnEnvironmentsSetUpEnd(*parent_) */ -> OnEnvironmentsSetUpEnd ( * parent_ ) ; |
| 5835: |
| 5836: |
| 5837: |
5838: if/* if (Test::IsSkipped()) {
// Emit diagnostics when global set-up calls skip, as it will not be
// emitted by default.
TestResult& test_result =
*internal::GetUnitTestImpl()->current_test_result();
for (int j = 0; j < test_result.total_part_count(); ++j) {
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
}
fflush(stdout);
} else if (!Test::HasFatalFailure()) {
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
}
} else if (Test::HasFatalFailure()) {
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
} */ Test :: IsSkipped ( ) ) {/*
// Emit diagnostics when global set-up calls skip, as it will not be
// emitted by default.
TestResult& test_result =
*internal::GetUnitTestImpl()->current_test_result();
for (int j = 0; j < test_result.total_part_count(); ++j) {
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
}
fflush(stdout);
*/ |
| 5839: |
| 5840: |
| 5841: TestResult & test_result = |
| 5842: * internal :: GetUnitTestImpl ( ) -> current_test_result ( ) ; |
5843: for/* for (int j = 0; j < test_result.total_part_count(); ++j) {
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
} */ ( int j = 0 ; j < test_result . total_part_count ( ) ; ++ j ) {/*
const TestPartResult& test_part_result =
test_result.GetTestPartResult(j);
if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
}
*/ |
| 5844: const TestPartResult & test_part_result = |
| 5845: test_result . GetTestPartResult ( j ) ; |
5846: if/* if (test_part_result.type() == TestPartResult::kSkip) {
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
} */ test_part_result . type ( ) == TestPartResult :: kSkip ) {/*
const std::string& result = test_part_result.message();
printf("%s\n", result.c_str());
*/ |
| 5847: const std :: string & result = test_part_result . message ( ) ; |
5848: printf/* printf("%s\n", result.c_str()) */ ( "%s\n" , result . c_str ( ) ) ; |
| 5849: } |
| 5850: } |
5851: fflush/* fflush(stdout) */ ( stdout ) ; |
| 5852: } else if/* if (!Test::HasFatalFailure()) {
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
}
} else if (Test::HasFatalFailure()) {
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
} */ (truefalse!!Test::HasFatalFailure() ! Test :: HasFatalFailure ( ) ) {/*
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
}
*/ |
5853: for/* for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
} */ ( int test_index = 0 ; test_index < total_test_suite_count ( ) ; |
| 5854: test_index ++ ) {/*
GetMutableSuiteCase(test_index)->Run();
if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
}
*/ |
5855: GetMutableSuiteCase/* GetMutableSuiteCase(test_index)->Run() */ ( test_index ) -> Run ( ) ; |
5856: if/* if (GTEST_FLAG(fail_fast) &&
GetMutableSuiteCase(test_index)->Failed()) {
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
} */ ( GTEST_FLAG ( fail_fast ) |
| 5857: GetMutableSuiteCase ( test_index ) -> Failed ( ) ) {/*
for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
}
break;
*/ |
5858: for/* for (int j = test_index + 1; j < total_test_suite_count(); j++) {
GetMutableSuiteCase(j)->Skip();
} */ ( int j = test_index + 1 ; j < total_test_suite_count ( ) ; j ++ ) {/*
GetMutableSuiteCase(j)->Skip();
*/ |
5859: GetMutableSuiteCase/* GetMutableSuiteCase(j)->Skip() */ ( j ) -> Skip ( ) ; |
| 5860: } |
| 5861: break ; |
| 5862: } |
| 5863: } |
| 5864: } else if/* if (Test::HasFatalFailure()) {
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
} */ Test :: HasFatalFailure ( ) ) {/*
// If there was a fatal failure during the global setup then we know we
// aren't going to run any tests. Explicitly mark all of the tests as
// skipped to make this obvious in the output.
for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
}
*/ |
| 5865: |
| 5866: |
| 5867: |
5868: for/* for (int test_index = 0; test_index < total_test_suite_count();
test_index++) {
GetMutableSuiteCase(test_index)->Skip();
} */ ( int test_index = 0 ; test_index < total_test_suite_count ( ) ; |
| 5869: test_index ++ ) {/*
GetMutableSuiteCase(test_index)->Skip();
*/ |
5870: GetMutableSuiteCase/* GetMutableSuiteCase(test_index)->Skip() */ ( test_index ) -> Skip ( ) ; |
| 5871: } |
| 5872: } |
| 5873: |
| 5874: |
5875: repeater/* repeater->OnEnvironmentsTearDownStart(*parent_) */ -> OnEnvironmentsTearDownStart ( * parent_ ) ; |
| 5876: std :: for_each ( environments_ . rbegin ( ) , environments_ . rend ( ) , |
| 5877: TearDownEnvironment ) ; |
5878: repeater/* repeater->OnEnvironmentsTearDownEnd(*parent_) */ -> OnEnvironmentsTearDownEnd ( * parent_ ) ; |
| 5879: } |
| 5880: |
5881: elapsed_time_/* elapsed_time_ = timer.Elapsed() */ = timer . Elapsed ( ) ; |
| 5882: |
| 5883: |
5884: repeater/* repeater->OnTestIterationEnd(*parent_, i) */ -> OnTestIterationEnd ( * parent_ , i ) ; |
| 5885: |
| 5886: |
5887: if/* if (!Passed()) {
failed = true;
} */ ! Passed ( ) ) |
5888: failed/* failed = true */ = true ; |
| 5889: } |
| 5890: |
| 5891: |
| 5892: |
| 5893: |
| 5894: |
| 5895: |
| 5896: |
5897: UnshuffleTests/* UnshuffleTests() */ ( ) ; |
| 5898: |
5899: if/* if (GTEST_FLAG(shuffle)) {
// Picks a new random seed for each iteration.
random_seed_ = GetNextRandomSeed(random_seed_);
} */ ( GTEST_FLAG ( shuffle ) ) {/*
// Picks a new random seed for each iteration.
random_seed_ = GetNextRandomSeed(random_seed_);
*/ |
| 5900: |
5901: random_seed_/* random_seed_ = GetNextRandomSeed(random_seed_) */ = GetNextRandomSeed ( random_seed_ ) ; |
| 5902: } |
| 5903: } |
| 5904: |
5905: repeater/* repeater->OnTestProgramEnd(*parent_) */ -> OnTestProgramEnd ( * parent_ ) ; |
| 5906: |
5907: if/* if (!gtest_is_initialized_before_run_all_tests) {
ColoredPrintf(
GTestColor::kRed,
"\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
"This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
"() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
" will start to enforce the valid usage. "
"Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT
#if GTEST_FOR_GOOGLE_
ColoredPrintf(GTestColor::kRed,
"For more details, see http://wiki/Main/ValidGUnitMain.\n");
#endif // GTEST_FOR_GOOGLE_
} */ (truefalse!!gtest_is_initialized_before_run_all_tests ! gtest_is_initialized_before_run_all_tests ) {/*
ColoredPrintf(
GTestColor::kRed,
"\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
"This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
"() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
" will start to enforce the valid usage. "
"Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT
#if GTEST_FOR_GOOGLE_
ColoredPrintf(GTestColor::kRed,
"For more details, see http://wiki/Main/ValidGUnitMain.\n");
#endif // GTEST_FOR_GOOGLE_
*/ |
5908: ColoredPrintf/* ColoredPrintf(
GTestColor::kRed,
"\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
"This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
"() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
" will start to enforce the valid usage. "
"Please fix it ASAP, or IT WILL START TO FAIL.\n") */ ( |
| 5909: GTestColor :: kRed , |
| 5910: "\nIMPORTANT NOTICE - DO NOT IGNORE:\n" |
| 5911: "This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_ |
| 5912: "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_ |
| 5913: " will start to enforce the valid usage. " |
| 5914: "Please fix it ASAP, or IT WILL START TO FAIL.\n" ) ; |
| 5915: # if GTEST_FOR_GOOGLE_ |
| 5916: ColoredPrintf ( GTestColor :: kRed , |
| 5917: "For more details, see http://wiki/Main/ValidGUnitMain.\n" ) ; |
| 5918: # endif |
| 5919: } |
| 5920: |
| 5921: return failed ; |
| 5922: } |
| 5923: |
| 5924: |
| 5925: |
| 5926: |
| 5927: |
| 5928: void WriteToShardStatusFileIfNeeded ( ) {/*
const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
if (test_shard_file != nullptr) {
FILE* const file = posix::FOpen(test_shard_file, "w");
if (file == nullptr) {
ColoredPrintf(GTestColor::kRed,
"Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n",
test_shard_file, kTestShardStatusFile);
fflush(stdout);
exit(EXIT_FAILURE);
}
fclose(file);
}
*/ |
| 5929: const char * const test_shard_file = posix :: GetEnv ( kTestShardStatusFile ) ; |
5930: if/* if (test_shard_file != nullptr) {
FILE* const file = posix::FOpen(test_shard_file, "w");
if (file == nullptr) {
ColoredPrintf(GTestColor::kRed,
"Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n",
test_shard_file, kTestShardStatusFile);
fflush(stdout);
exit(EXIT_FAILURE);
}
fclose(file);
} */ test_shard_file != nullptr ) {/*
FILE* const file = posix::FOpen(test_shard_file, "w");
if (file == nullptr) {
ColoredPrintf(GTestColor::kRed,
"Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n",
test_shard_file, kTestShardStatusFile);
fflush(stdout);
exit(EXIT_FAILURE);
}
fclose(file);
*/ |
| 5931: FILE * const file = posix :: FOpen ( test_shard_file , "w" ) ; |
5932: if/* if (file == nullptr) {
ColoredPrintf(GTestColor::kRed,
"Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n",
test_shard_file, kTestShardStatusFile);
fflush(stdout);
exit(EXIT_FAILURE);
} */ file == nullptr ) {/*
ColoredPrintf(GTestColor::kRed,
"Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n",
test_shard_file, kTestShardStatusFile);
fflush(stdout);
exit(EXIT_FAILURE);
*/ |
5933: ColoredPrintf/* ColoredPrintf(GTestColor::kRed,
"Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n",
test_shard_file, kTestShardStatusFile) */ ( GTestColor :: kRed , |
| 5934: "Could not write to the test shard status file \"%s\" " |
| 5935: "specified by the %s environment variable.\n" , |
| 5936: test_shard_file , kTestShardStatusFile ) ; |
5937: fflush/* fflush(stdout) */ ( stdout ) ; |
5938: exit/* exit(EXIT_FAILURE) */ ( EXIT_FAILURE ) ; |
| 5939: } |
| 5940: ( file ) ; |
| 5941: } |
| 5942: } |
| 5943: |
| 5944: |
| 5945: |
| 5946: |
| 5947: |
| 5948: |
| 5949: |
| 5950: bool ShouldShard ( const char * total_shards_env , |
| 5951: const char * shard_index_env , |
| 5952: bool in_subprocess_for_death_test ) { |
| 5953: if in_subprocess_for_death_test ) { |
| 5954: return ; |
| 5955: } |
| 5956: |
| 5957: const int32_t total_shards = Int32FromEnvOrDie ( total_shards_env , - 1 ) ; |
| 5958: const int32_t shard_index = Int32FromEnvOrDie ( shard_index_env , - 1 ) ; |
| 5959: |
| 5960: if (truefalsetruefalsetruefalse total_shards == - 1 == - 1 ) { |
| 5961: return ; |
| 5962: } else if/* if (total_shards == -1 && shard_index != -1) {
const Message msg = Message()
<< "Invalid environment variables: you have "
<< kTestShardIndex << " = " << shard_index
<< ", but have left " << kTestTotalShards << " unset.\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} else if (total_shards != -1 && shard_index == -1) {
const Message msg = Message()
<< "Invalid environment variables: you have "
<< kTestTotalShards << " = " << total_shards
<< ", but have left " << kTestShardIndex << " unset.\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} else if (shard_index < 0 || shard_index >= total_shards) {
const Message msg = Message()
<< "Invalid environment variables: we require 0 <= "
<< kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index
<< ", " << kTestTotalShards << "=" << total_shards << ".\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} */ (truefalsetruefalsetruefalse total_shards == - 1 != - 1 ) {/*
const Message msg = Message()
<< "Invalid environment variables: you have "
<< kTestShardIndex << " = " << shard_index
<< ", but have left " << kTestTotalShards << " unset.\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
*/ |
| 5963: const Message msg = Message ( ) |
| 5964: << "Invalid environment variables: you have " |
| 5965: << kTestShardIndex << " = " << shard_index |
| 5966: << ", but have left " << kTestTotalShards << " unset.\n" ; |
| 5967: ColoredPrintf ( GTestColor :: kRed , "%s" , msg . GetString ( ) . c_str ( ) ) ; |
5968: fflush/* fflush(stdout) */ ( stdout ) ; |
5969: exit/* exit(EXIT_FAILURE) */ ( EXIT_FAILURE ) ; |
| 5970: } else if/* if (total_shards != -1 && shard_index == -1) {
const Message msg = Message()
<< "Invalid environment variables: you have "
<< kTestTotalShards << " = " << total_shards
<< ", but have left " << kTestShardIndex << " unset.\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} else if (shard_index < 0 || shard_index >= total_shards) {
const Message msg = Message()
<< "Invalid environment variables: we require 0 <= "
<< kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index
<< ", " << kTestTotalShards << "=" << total_shards << ".\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} */ (truefalsetruefalsetruefalse total_shards != - 1 == - 1 ) {/*
const Message msg = Message()
<< "Invalid environment variables: you have "
<< kTestTotalShards << " = " << total_shards
<< ", but have left " << kTestShardIndex << " unset.\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
*/ |
| 5971: const Message msg = Message ( ) |
| 5972: << "Invalid environment variables: you have " |
| 5973: << kTestTotalShards << " = " << total_shards |
| 5974: << ", but have left " << kTestShardIndex << " unset.\n" ; |
| 5975: ColoredPrintf ( GTestColor :: kRed , "%s" , msg . GetString ( ) . c_str ( ) ) ; |
5976: fflush/* fflush(stdout) */ ( stdout ) ; |
5977: exit/* exit(EXIT_FAILURE) */ ( EXIT_FAILURE ) ; |
| 5978: } else if/* if (shard_index < 0 || shard_index >= total_shards) {
const Message msg = Message()
<< "Invalid environment variables: we require 0 <= "
<< kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index
<< ", " << kTestTotalShards << "=" << total_shards << ".\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} */ (truefalsetruefalsetruefalse shard_index < 0 >= total_shards ) {/*
const Message msg = Message()
<< "Invalid environment variables: we require 0 <= "
<< kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index
<< ", " << kTestTotalShards << "=" << total_shards << ".\n";
ColoredPrintf(GTestColor::kRed, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
*/ |
| 5979: const Message msg = Message ( ) |
| 5980: << "Invalid environment variables: we require 0 <= " |
| 5981: << kTestShardIndex << " < " << kTestTotalShards |
| 5982: << ", but you have " << kTestShardIndex << "=" << shard_index |
| 5983: << ", " << kTestTotalShards << "=" << total_shards << ".\n" ; |
| 5984: ColoredPrintf ( GTestColor :: kRed , "%s" , msg . GetString ( ) . c_str ( ) ) ; |
5985: fflush/* fflush(stdout) */ ( stdout ) ; |
5986: exit/* exit(EXIT_FAILURE) */ ( EXIT_FAILURE ) ; |
| 5987: } |
| 5988: |
| 5989: return > 1 ; |
| 5990: } |
| 5991: |
| 5992: |
| 5993: |
| 5994: |
| 5995: int32_t Int32FromEnvOrDie ( const char * var , int32_t default_val ) { |
| 5996: const char * str_val = posix :: GetEnv ( var ) ; |
| 5997: if str_val == nullptr ) { |
| 5998: return default_val ; |
| 5999: } |
| 6000: |
| 6001: int32_t result ; |
6002: if/* if (!ParseInt32(Message() << "The value of environment variable " << var,
str_val, &result)) {
exit(EXIT_FAILURE);
} */ (truefalse!!ParseInt32(Message() << "The value of environment variable " << var,
str_val, &result) ! ParseInt32 ( Message ( ) << "The value of environment variable " << var , |
| 6003: str_val , & result ) ) {/*
exit(EXIT_FAILURE);
*/ |
6004: exit/* exit(EXIT_FAILURE) */ ( EXIT_FAILURE ) ; |
| 6005: } |
| 6006: return result ; |
| 6007: } |
| 6008: |
| 6009: |
| 6010: |
| 6011: |
| 6012: |
| 6013: bool ShouldRunTestOnShard ( int total_shards , int shard_index , int test_id ) { |
| 6014: return test_id % total_shards ) == shard_index ; |
| 6015: } |
| 6016: |
| 6017: |
| 6018: |
| 6019: |
| 6020: |
| 6021: |
| 6022: |
| 6023: |
| 6024: int UnitTestImpl :: FilterTests ( ReactionToSharding shard_tests ) { |
| 6025: const int32_t total_shards = == HONOR_SHARDING_PROTOCOL ? |
| 6026: Int32FromEnvOrDie ( kTestTotalShards , - 1 ) : - 1 ; |
| 6027: const int32_t shard_index = == HONOR_SHARDING_PROTOCOL ? |
| 6028: Int32FromEnvOrDie ( kTestShardIndex , - 1 ) : - 1 ; |
| 6029: |
| 6030: |
| 6031: |
| 6032: |
| 6033: |
| 6034: int num_runnable_tests = 0 ; |
| 6035: int num_selected_tests = 0 ; |
6036: for/* for (auto* test_suite : test_suites_) {
const std::string& test_suite_name = test_suite->name();
test_suite->set_should_run(false);
for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
TestInfo* const test_info = test_suite->test_info_list()[j];
const std::string test_name(test_info->name());
// A test is disabled if test suite name or test name matches
// kDisableTestFilter.
const bool is_disabled = internal::UnitTestOptions::MatchesFilter(
test_suite_name, kDisableTestFilter) ||
internal::UnitTestOptions::MatchesFilter(
test_name, kDisableTestFilter);
test_info->is_disabled_ = is_disabled;
const bool matches_filter = internal::UnitTestOptions::FilterMatchesTest(
test_suite_name, test_name);
test_info->matches_filter_ = matches_filter;
const bool is_runnable =
(GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
matches_filter;
const bool is_in_another_shard =
shard_tests != IGNORE_SHARDING_PROTOCOL &&
!ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
test_info->is_in_another_shard_ = is_in_another_shard;
const bool is_selected = is_runnable && !is_in_another_shard;
num_runnable_tests += is_runnable;
num_selected_tests += is_selected;
test_info->should_run_ = is_selected;
test_suite->set_should_run(test_suite->should_run() || is_selected);
}
} */ ( auto * test_suite : test_suites_ ) {/*
const std::string& test_suite_name = test_suite->name();
test_suite->set_should_run(false);
for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
TestInfo* const test_info = test_suite->test_info_list()[j];
const std::string test_name(test_info->name());
// A test is disabled if test suite name or test name matches
// kDisableTestFilter.
const bool is_disabled = internal::UnitTestOptions::MatchesFilter(
test_suite_name, kDisableTestFilter) ||
internal::UnitTestOptions::MatchesFilter(
test_name, kDisableTestFilter);
test_info->is_disabled_ = is_disabled;
const bool matches_filter = internal::UnitTestOptions::FilterMatchesTest(
test_suite_name, test_name);
test_info->matches_filter_ = matches_filter;
const bool is_runnable =
(GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
matches_filter;
const bool is_in_another_shard =
shard_tests != IGNORE_SHARDING_PROTOCOL &&
!ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
test_info->is_in_another_shard_ = is_in_another_shard;
const bool is_selected = is_runnable && !is_in_another_shard;
num_runnable_tests += is_runnable;
num_selected_tests += is_selected;
test_info->should_run_ = is_selected;
test_suite->set_should_run(test_suite->should_run() || is_selected);
}
*/ |
| 6037: const std :: string & test_suite_name = test_suite -> name ( ) ; |
6038: test_suite/* test_suite->set_should_run(false) */ -> set_should_run ( false ) ; |
| 6039: |
6040: for/* for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
TestInfo* const test_info = test_suite->test_info_list()[j];
const std::string test_name(test_info->name());
// A test is disabled if test suite name or test name matches
// kDisableTestFilter.
const bool is_disabled = internal::UnitTestOptions::MatchesFilter(
test_suite_name, kDisableTestFilter) ||
internal::UnitTestOptions::MatchesFilter(
test_name, kDisableTestFilter);
test_info->is_disabled_ = is_disabled;
const bool matches_filter = internal::UnitTestOptions::FilterMatchesTest(
test_suite_name, test_name);
test_info->matches_filter_ = matches_filter;
const bool is_runnable =
(GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
matches_filter;
const bool is_in_another_shard =
shard_tests != IGNORE_SHARDING_PROTOCOL &&
!ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
test_info->is_in_another_shard_ = is_in_another_shard;
const bool is_selected = is_runnable && !is_in_another_shard;
num_runnable_tests += is_runnable;
num_selected_tests += is_selected;
test_info->should_run_ = is_selected;
test_suite->set_should_run(test_suite->should_run() || is_selected);
} */ ( size_t j = 0 ; j < test_suite -> test_info_list ( ) . size ( ) ; j ++ ) {/*
TestInfo* const test_info = test_suite->test_info_list()[j];
const std::string test_name(test_info->name());
// A test is disabled if test suite name or test name matches
// kDisableTestFilter.
const bool is_disabled = internal::UnitTestOptions::MatchesFilter(
test_suite_name, kDisableTestFilter) ||
internal::UnitTestOptions::MatchesFilter(
test_name, kDisableTestFilter);
test_info->is_disabled_ = is_disabled;
const bool matches_filter = internal::UnitTestOptions::FilterMatchesTest(
test_suite_name, test_name);
test_info->matches_filter_ = matches_filter;
const bool is_runnable =
(GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
matches_filter;
const bool is_in_another_shard =
shard_tests != IGNORE_SHARDING_PROTOCOL &&
!ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
test_info->is_in_another_shard_ = is_in_another_shard;
const bool is_selected = is_runnable && !is_in_another_shard;
num_runnable_tests += is_runnable;
num_selected_tests += is_selected;
test_info->should_run_ = is_selected;
test_suite->set_should_run(test_suite->should_run() || is_selected);
*/ |
| 6041: TestInfo * const test_info = test_suite -> test_info_list ( ) [ j ] ; |
| 6042: const std :: string test_name ( test_info -> name ( ) ) ; |
| 6043: |
| 6044: |
| 6045: const bool is_disabled = internaltruefalsetruefalse :: UnitTestOptions :: MatchesFilter ( |
| 6046: test_suite_name , kDisableTestFilter ) |
| 6047: internal :: UnitTestOptions :: MatchesFilter ( |
| 6048: test_name , kDisableTestFilter ) ; |
6049: test_info/* test_info->is_disabled_ = is_disabled */ -> is_disabled_ = is_disabled ; |
| 6050: |
| 6051: const bool matches_filter = internal :: UnitTestOptions :: FilterMatchesTest ( |
| 6052: test_suite_name , test_name ) ; |
6053: test_info/* test_info->matches_filter_ = matches_filter */ -> matches_filter_ = matches_filter ; |
| 6054: |
| 6055: const bool is_runnable = |
| 6056: GTEST_FLAG ( also_run_disabled_tests ) is_disabled ) |
| 6057: matches_filter ; |
| 6058: |
| 6059: const bool is_in_another_shard = |
6060: shard_teststruefalsetruefalsetruefalse != IGNORE_SHARDING_PROTOCOL |
6061: !!!ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests) ShouldRunTestOnShard ( total_shards , shard_index , num_runnable_tests ) ; |
6062: test_info/* test_info->is_in_another_shard_ = is_in_another_shard */ -> is_in_another_shard_ = is_in_another_shard ; |
| 6063: const bool is_selected = is_runnabletruefalsetruefalse is_in_another_shard ; |
| 6064: |
6065: num_runnable_tests/* num_runnable_tests += is_runnable */ += is_runnable ; |
6066: num_selected_tests/* num_selected_tests += is_selected */ += is_selected ; |
| 6067: |
6068: test_info/* test_info->should_run_ = is_selected */ -> should_run_ = is_selected ; |
6069: test_suite/* test_suite->set_should_run(test_suite->should_run() || is_selected) */ -> set_should_run test_suite -> should_run ( ) is_selected ) ; |
| 6070: } |
| 6071: } |
| 6072: return num_selected_tests ; |
| 6073: } |
| 6074: |
| 6075: |
| 6076: |
| 6077: |
| 6078: |
| 6079: static void PrintOnOneLine ( const char * str , int max_length ) {/*
if (str != nullptr) {
for (int i = 0; *str != '\0'; ++str) {
if (i >= max_length) {
printf("...");
break;
}
if (*str == '\n') {
printf("\\n");
i += 2;
} else {
printf("%c", *str);
++i;
}
}
}
*/ |
6080: if/* if (str != nullptr) {
for (int i = 0; *str != '\0'; ++str) {
if (i >= max_length) {
printf("...");
break;
}
if (*str == '\n') {
printf("\\n");
i += 2;
} else {
printf("%c", *str);
++i;
}
}
} */ str != nullptr ) {/*
for (int i = 0; *str != '\0'; ++str) {
if (i >= max_length) {
printf("...");
break;
}
if (*str == '\n') {
printf("\\n");
i += 2;
} else {
printf("%c", *str);
++i;
}
}
*/ |
6081: for/* for (int i = 0; *str != '\0'; ++str) {
if (i >= max_length) {
printf("...");
break;
}
if (*str == '\n') {
printf("\\n");
i += 2;
} else {
printf("%c", *str);
++i;
}
} */ ( int i = 0 ; * str != '\0' ; ++ str ) {/*
if (i >= max_length) {
printf("...");
break;
}
if (*str == '\n') {
printf("\\n");
i += 2;
} else {
printf("%c", *str);
++i;
}
*/ |
6082: if/* if (i >= max_length) {
printf("...");
break;
} */ i >= max_length ) {/*
printf("...");
break;
*/ |
6083: printf/* printf("...") */ ( "..." ) ; |
| 6084: break ; |
| 6085: } |
6086: if/* if (*str == '\n') {
printf("\\n");
i += 2;
} else {
printf("%c", *str);
++i;
} */ * str == '\n' ) {/*
printf("\\n");
i += 2;
*/ |
6087: printf/* printf("\\n") */ ( "\\n" ) ; |
| 6088: += 2 ; |
| 6089: } else {/*
printf("%c", *str);
++i;
*/ |
6090: printf/* printf("%c", *str) */ ( "%c" , * str ) ; |
| 6091: i ; |
| 6092: } |
| 6093: } |
| 6094: } |
| 6095: } |
| 6096: |
| 6097: |
| 6098: void UnitTestImpl :: ListTestsMatchingFilter ( ) {/*
// Print at most this many characters for each type/value parameter.
const int kMaxParamLength = 250;
for (auto* test_suite : test_suites_) {
bool printed_test_suite_name = false;
for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
const TestInfo* const test_info = test_suite->test_info_list()[j];
if (test_info->matches_filter_) {
if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
}
}
}
fflush(stdout);
const std::string& output_format = UnitTestOptions::GetOutputFormat();
if (output_format == "xml" || output_format == "json") {
FILE* fileout = OpenFileForWriting(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
std::stringstream stream;
if (output_format == "xml") {
XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintXmlTestsList(&stream, test_suites_);
} else if (output_format == "json") {
JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintJsonTestList(&stream, test_suites_);
}
fprintf(fileout, "%s", StringStreamToString(&stream).c_str());
fclose(fileout);
}
*/ |
| 6099: |
| 6100: const int kMaxParamLength = 250 ; |
| 6101: |
6102: for/* for (auto* test_suite : test_suites_) {
bool printed_test_suite_name = false;
for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
const TestInfo* const test_info = test_suite->test_info_list()[j];
if (test_info->matches_filter_) {
if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
}
}
} */ ( auto * test_suite : test_suites_ ) {/*
bool printed_test_suite_name = false;
for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
const TestInfo* const test_info = test_suite->test_info_list()[j];
if (test_info->matches_filter_) {
if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
}
}
*/ |
| 6103: bool printed_test_suite_name = false ; |
| 6104: |
6105: for/* for (size_t j = 0; j < test_suite->test_info_list().size(); j++) {
const TestInfo* const test_info = test_suite->test_info_list()[j];
if (test_info->matches_filter_) {
if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
}
} */ ( size_t j = 0 ; j < test_suite -> test_info_list ( ) . size ( ) ; j ++ ) {/*
const TestInfo* const test_info = test_suite->test_info_list()[j];
if (test_info->matches_filter_) {
if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
}
*/ |
| 6106: const TestInfo * const test_info = test_suite -> test_info_list ( ) [ j ] ; |
6107: if/* if (test_info->matches_filter_) {
if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
} */ test_info -> matches_filter_ ) {/*
if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
*/ |
6108: if/* if (!printed_test_suite_name) {
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
} */ (truefalse!!printed_test_suite_name ! printed_test_suite_name ) {/*
printed_test_suite_name = true;
printf("%s.", test_suite->name());
if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
}
printf("\n");
*/ |
6109: printed_test_suite_name/* printed_test_suite_name = true */ = true ; |
6110: printf/* printf("%s.", test_suite->name()) */ ( "%s." , test_suite -> name ( ) ) ; |
6111: if/* if (test_suite->type_param() != nullptr) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
} */ test_suite -> type_param ( ) != nullptr ) {/*
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_suite->type_param(), kMaxParamLength);
*/ |
6112: printf/* printf(" # %s = ", kTypeParamLabel) */ ( " # %s = " , kTypeParamLabel ) ; |
| 6113: |
| 6114: |
6115: PrintOnOneLine/* PrintOnOneLine(test_suite->type_param(), kMaxParamLength) */ ( test_suite -> type_param ( ) , kMaxParamLength ) ; |
| 6116: } |
| 6117: ( "\n" ) ; |
| 6118: } |
6119: printf/* printf(" %s", test_info->name()) */ ( " %s" , test_info -> name ( ) ) ; |
6120: if/* if (test_info->value_param() != nullptr) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
} */ test_info -> value_param ( ) != nullptr ) {/*
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
*/ |
6121: printf/* printf(" # %s = ", kValueParamLabel) */ ( " # %s = " , kValueParamLabel ) ; |
| 6122: |
| 6123: |
6124: PrintOnOneLine/* PrintOnOneLine(test_info->value_param(), kMaxParamLength) */ ( test_info -> value_param ( ) , kMaxParamLength ) ; |
| 6125: } |
| 6126: ( "\n" ) ; |
| 6127: } |
| 6128: } |
| 6129: } |
6130: fflush/* fflush(stdout) */ ( stdout ) ; |
| 6131: const std :: string & output_format = UnitTestOptions :: GetOutputFormat ( ) ; |
6132: if/* if (output_format == "xml" || output_format == "json") {
FILE* fileout = OpenFileForWriting(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
std::stringstream stream;
if (output_format == "xml") {
XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintXmlTestsList(&stream, test_suites_);
} else if (output_format == "json") {
JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintJsonTestList(&stream, test_suites_);
}
fprintf(fileout, "%s", StringStreamToString(&stream).c_str());
fclose(fileout);
} */ (truefalsetruefalsetruefalse output_format == "xml" == "json" ) {/*
FILE* fileout = OpenFileForWriting(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str());
std::stringstream stream;
if (output_format == "xml") {
XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintXmlTestsList(&stream, test_suites_);
} else if (output_format == "json") {
JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintJsonTestList(&stream, test_suites_);
}
fprintf(fileout, "%s", StringStreamToString(&stream).c_str());
fclose(fileout);
*/ |
| 6133: FILE * fileout = OpenFileForWriting ( |
| 6134: UnitTestOptions :: GetAbsolutePathToOutputFile ( ) . c_str ( ) ) ; |
| 6135: std :: stringstream stream ; |
6136: if/* if (output_format == "xml") {
XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintXmlTestsList(&stream, test_suites_);
} else if (output_format == "json") {
JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintJsonTestList(&stream, test_suites_);
} */ output_format == "xml" ) {/*
XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintXmlTestsList(&stream, test_suites_);
*/ |
| 6137: XmlUnitTestResultPrinter ( |
| 6138: UnitTestOptions :: GetAbsolutePathToOutputFile ( ) . c_str ( ) ) |
| 6139: . PrintXmlTestsList ( & stream , test_suites_ ) ; |
| 6140: } else if/* if (output_format == "json") {
JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintJsonTestList(&stream, test_suites_);
} */ output_format == "json" ) {/*
JsonUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str())
.PrintJsonTestList(&stream, test_suites_);
*/ |
| 6141: JsonUnitTestResultPrinter ( |
| 6142: UnitTestOptions :: GetAbsolutePathToOutputFile ( ) . c_str ( ) ) |
| 6143: . PrintJsonTestList ( & stream , test_suites_ ) ; |
| 6144: } |
| 6145: fprintf ( fileout , "%s" , StringStreamToString ( & stream ) . c_str ( ) ) ; |
6146: fclose/* fclose(fileout) */ ( fileout ) ; |
| 6147: } |
| 6148: } |
| 6149: |
| 6150: |
| 6151: |
| 6152: |
| 6153: |
| 6154: |
| 6155: void UnitTestImpl :: set_os_stack_trace_getter ( |
| 6156: OsStackTraceGetterInterface * getter ) {/*
if (os_stack_trace_getter_ != getter) {
delete os_stack_trace_getter_;
os_stack_trace_getter_ = getter;
}
*/ |
6157: if/* if (os_stack_trace_getter_ != getter) {
delete os_stack_trace_getter_;
os_stack_trace_getter_ = getter;
} */ os_stack_trace_getter_ != getter ) {/*
delete os_stack_trace_getter_;
os_stack_trace_getter_ = getter;
*/ |
| 6158: delete os_stack_trace_getter_ ; |
6159: os_stack_trace_getter_/* os_stack_trace_getter_ = getter */ = getter ; |
| 6160: } |
| 6161: } |
| 6162: |
| 6163: |
| 6164: |
| 6165: |
| 6166: OsStackTraceGetterInterface * UnitTestImpl :: os_stack_trace_getter ( ) { |
6167: if/* if (os_stack_trace_getter_ == nullptr) {
#ifdef GTEST_OS_STACK_TRACE_GETTER_
os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;
#else
os_stack_trace_getter_ = new OsStackTraceGetter;
#endif // GTEST_OS_STACK_TRACE_GETTER_
} */ os_stack_trace_getter_ == nullptr ) {/*
#ifdef GTEST_OS_STACK_TRACE_GETTER_
os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;
#else
os_stack_trace_getter_ = new OsStackTraceGetter;
#endif // GTEST_OS_STACK_TRACE_GETTER_
*/ |
| 6168: # ifdef GTEST_OS_STACK_TRACE_GETTER_ |
| 6169: os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_ ; |
| 6170: # else |
6171: os_stack_trace_getter_/* os_stack_trace_getter_ = new OsStackTraceGetter */ = new OsStackTraceGetter ; |
| 6172: # endif |
| 6173: } |
| 6174: |
| 6175: return os_stack_trace_getter_ ; |
| 6176: } |
| 6177: |
| 6178: |
| 6179: TestResult * UnitTestImpl :: current_test_result ( ) { |
| 6180: if current_test_info_ != nullptr ) { |
| 6181: return & current_test_info_ -> result_ ; |
| 6182: } |
| 6183: if current_test_suite_ != nullptr ) { |
| 6184: return & current_test_suite_ -> ad_hoc_test_result_ ; |
| 6185: } |
| 6186: return & ad_hoc_test_result_ ; |
| 6187: } |
| 6188: |
| 6189: |
| 6190: |
| 6191: void UnitTestImpl :: ShuffleTests ( ) {/*
// Shuffles the death test suites.
ShuffleRange(random(), 0, last_death_test_suite_ + 1, &test_suite_indices_);
// Shuffles the non-death test suites.
ShuffleRange(random(), last_death_test_suite_ + 1,
static_cast<int>(test_suites_.size()), &test_suite_indices_);
// Shuffles the tests inside each test suite.
for (auto& test_suite : test_suites_) {
test_suite->ShuffleTests(random());
}
*/ |
| 6192: |
6193: ShuffleRange/* ShuffleRange(random(), 0, last_death_test_suite_ + 1, &test_suite_indices_) */ ( random ( ) , 0 , last_death_test_suite_ + 1 , & test_suite_indices_ ) ; |
| 6194: |
| 6195: |
6196: ShuffleRange/* ShuffleRange(random(), last_death_test_suite_ + 1,
static_cast<int>(test_suites_.size()), &test_suite_indices_) */ ( random ( ) , last_death_test_suite_ + 1 , |
| 6197: static_cast < int > ( test_suites_ . size ( ) ) , & test_suite_indices_ ) ; |
| 6198: |
| 6199: |
6200: for/* for (auto& test_suite : test_suites_) {
test_suite->ShuffleTests(random());
} */ ( auto & test_suite : test_suites_ ) {/*
test_suite->ShuffleTests(random());
*/ |
6201: test_suite/* test_suite->ShuffleTests(random()) */ -> ShuffleTests ( random ( ) ) ; |
| 6202: } |
| 6203: } |
| 6204: |
| 6205: |
| 6206: void UnitTestImpl :: UnshuffleTests ( ) {/*
for (size_t i = 0; i < test_suites_.size(); i++) {
// Unshuffles the tests in each test suite.
test_suites_[i]->UnshuffleTests();
// Resets the index of each test suite.
test_suite_indices_[i] = static_cast<int>(i);
}
*/ |
6207: for/* for (size_t i = 0; i < test_suites_.size(); i++) {
// Unshuffles the tests in each test suite.
test_suites_[i]->UnshuffleTests();
// Resets the index of each test suite.
test_suite_indices_[i] = static_cast<int>(i);
} */ ( size_t i = 0 ; i < test_suites_ . size ( ) ; i ++ ) {/*
// Unshuffles the tests in each test suite.
test_suites_[i]->UnshuffleTests();
// Resets the index of each test suite.
test_suite_indices_[i] = static_cast<int>(i);
*/ |
| 6208: |
6209: test_suites_/* test_suites_[i]->UnshuffleTests() */ [ i ] -> UnshuffleTests ( ) ; |
| 6210: |
6211: test_suite_indices_/* test_suite_indices_[i] = static_cast<int>(i) */ [ i ] = static_cast < int > ( i ) ; |
| 6212: } |
| 6213: } |
| 6214: |
| 6215: |
| 6216: |
| 6217: |
| 6218: |
| 6219: |
| 6220: |
| 6221: |
| 6222: |
| 6223: |
| 6224: |
| 6225: std :: string GetCurrentOsStackTraceExceptTop ( UnitTest * , |
| 6226: int skip_count ) { |
| 6227: |
| 6228: |
| 6229: return GetUnitTestImpl ( ) -> CurrentOsStackTraceExceptTop ( skip_count + 1 ) ; |
| 6230: } |
| 6231: |
| 6232: |
| 6233: |
| 6234: namespace { |
| 6235: class ClassUniqueToAlwaysTrue { } ; |
| 6236: } |
| 6237: |
| 6238: bool IsTrue ( bool condition ) { return ; } |
| 6239: |
| 6240: bool AlwaysTrue ( ) { |
| 6241: # if GTEST_HAS_EXCEPTIONS |
| 6242: |
| 6243: |
| 6244: if IsTrue ( false ) ) |
| 6245: throw ClassUniqueToAlwaysTrue ( ) ; |
| 6246: # endif |
| 6247: return ; |
| 6248: } |
| 6249: |
| 6250: |
| 6251: |
| 6252: |
| 6253: bool SkipPrefix ( const char * prefix , const char * * pstr ) { |
| 6254: const size_t prefix_len = strlen ( prefix ) ; |
| 6255: if strncmp ( * pstr , prefix , prefix_len ) == 0 ) { |
6256: */* *pstr += prefix_len */ pstr += prefix_len ; |
| 6257: return ; |
| 6258: } |
| 6259: return ; |
| 6260: } |
| 6261: |
| 6262: |
| 6263: |
| 6264: |
| 6265: |
| 6266: |
| 6267: static const char * ParseFlagValue ( const char * str , const char * flag , |
| 6268: bool def_optional ) { |
| 6269: |
| 6270: if (truefalsetruefalsetruefalse str == nullptr == nullptr ) return nullptr ; |
| 6271: |
| 6272: |
| 6273: const std :: string flag_str = std :: string ( "--" ) + GTEST_FLAG_PREFIX_ + flag ; |
| 6274: const size_t flag_len = flag_str . length ( ) ; |
| 6275: if strncmp ( str , flag_str . c_str ( ) , flag_len ) != 0 ) return nullptr ; |
| 6276: |
| 6277: |
| 6278: const char * flag_end = str + flag_len ; |
| 6279: |
| 6280: |
| 6281: if def_optional flag_end [ 0 ] == '\0' ) ) { |
| 6282: return flag_end ; |
| 6283: } |
| 6284: |
| 6285: |
| 6286: |
| 6287: |
| 6288: if flag_end [ 0 ] != '=' ) return nullptr ; |
| 6289: |
| 6290: |
| 6291: return flag_end + 1 ; |
| 6292: } |
| 6293: |
| 6294: |
| 6295: |
| 6296: |
| 6297: |
| 6298: |
| 6299: |
| 6300: |
| 6301: |
| 6302: |
| 6303: |
| 6304: static bool ParseBoolFlag ( const char * str , const char * flag , bool * value ) { |
| 6305: |
| 6306: const char * const value_str = ParseFlagValue ( str , flag , true ) ; |
| 6307: |
| 6308: |
| 6309: if value_str == nullptr ) return ; |
| 6310: |
| 6311: |
6312: */* *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F') */ value = !!!(*value_str == '0' || *value_str == 'f' || *value_str == 'F') (truefalsetruefalsetruefalsetruefalsetruefalse * value_str == '0' value_str == 'f' value_str == 'F' ) ; |
| 6313: return ; |
| 6314: } |
| 6315: |
| 6316: |
| 6317: |
| 6318: |
| 6319: |
| 6320: bool ParseInt32Flag ( const char * str , const char * flag , int32_t * value ) { |
| 6321: |
| 6322: const char * const value_str = ParseFlagValue ( str , flag , false ) ; |
| 6323: |
| 6324: |
| 6325: if value_str == nullptr ) return ; |
| 6326: |
| 6327: |
| 6328: return ( Message ( ) << "The value of flag --" << flag , |
| 6329: value_str , value ) ; |
| 6330: } |
| 6331: |
| 6332: |
| 6333: |
| 6334: |
| 6335: |
| 6336: template < typename String > |
| 6337: static bool ParseStringFlag ( const char * str , const char * flag , String * value ) { |
| 6338: |
| 6339: const char * const value_str = ParseFlagValue ( str , flag , false ) ; |
| 6340: |
| 6341: |
| 6342: if value_str == nullptr ) return ; |
| 6343: |
| 6344: |
6345: */* *value = value_str */ value = value_str ; |
| 6346: return ; |
| 6347: } |
| 6348: |
| 6349: |
| 6350: |
| 6351: |
| 6352: |
| 6353: |
| 6354: |
| 6355: static bool HasGoogleTestFlagPrefix ( const char * str ) { |
| 6356: return (truefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalse SkipPrefix ( "--" , & str ) |
| 6357: SkipPrefix ( "-" , & str ) |
| 6358: SkipPrefix ( "/" , & str ) ) |
6359: !!!SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) SkipPrefix ( GTEST_FLAG_PREFIX_ "internal_" , & str ) |
| 6360: SkipPrefix ( GTEST_FLAG_PREFIX_ , & str ) |
| 6361: SkipPrefix ( GTEST_FLAG_PREFIX_DASH_ , & str ) ) ; |
| 6362: } |
| 6363: |
| 6364: |
| 6365: |
| 6366: |
| 6367: |
| 6368: |
| 6369: |
| 6370: |
| 6371: |
| 6372: |
| 6373: static void PrintColorEncoded ( const char * str ) {/*
GTestColor color = GTestColor::kDefault; // The current color.
// Conceptually, we split the string into segments divided by escape
// sequences. Then we print one segment at a time. At the end of
// each iteration, the str pointer advances to the beginning of the
// next segment.
for (;;) {
const char* p = strchr(str, '@');
if (p == nullptr) {
ColoredPrintf(color, "%s", str);
return;
}
ColoredPrintf(color, "%s", std::string(str, p).c_str());
const char ch = p[1];
str = p + 2;
if (ch == '@') {
ColoredPrintf(color, "@");
} else if (ch == 'D') {
color = GTestColor::kDefault;
} else if (ch == 'R') {
color = GTestColor::kRed;
} else if (ch == 'G') {
color = GTestColor::kGreen;
} else if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
}
}
*/ |
| 6374: GTestColor color = GTestColor :: kDefault ; |
| 6375: |
| 6376: |
| 6377: |
| 6378: |
| 6379: |
6380: for/* for (;;) {
const char* p = strchr(str, '@');
if (p == nullptr) {
ColoredPrintf(color, "%s", str);
return;
}
ColoredPrintf(color, "%s", std::string(str, p).c_str());
const char ch = p[1];
str = p + 2;
if (ch == '@') {
ColoredPrintf(color, "@");
} else if (ch == 'D') {
color = GTestColor::kDefault;
} else if (ch == 'R') {
color = GTestColor::kRed;
} else if (ch == 'G') {
color = GTestColor::kGreen;
} else if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
}
} */ ( ; ; ) {/*
const char* p = strchr(str, '@');
if (p == nullptr) {
ColoredPrintf(color, "%s", str);
return;
}
ColoredPrintf(color, "%s", std::string(str, p).c_str());
const char ch = p[1];
str = p + 2;
if (ch == '@') {
ColoredPrintf(color, "@");
} else if (ch == 'D') {
color = GTestColor::kDefault;
} else if (ch == 'R') {
color = GTestColor::kRed;
} else if (ch == 'G') {
color = GTestColor::kGreen;
} else if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
}
*/ |
| 6381: const char * p = strchr ( str , '@' ) ; |
6382: if/* if (p == nullptr) {
ColoredPrintf(color, "%s", str);
return;
} */ p == nullptr ) {/*
ColoredPrintf(color, "%s", str);
return;
*/ |
6383: ColoredPrintf/* ColoredPrintf(color, "%s", str) */ ( color , "%s" , str ) ; |
| 6384: ; |
| 6385: } |
| 6386: |
| 6387: ColoredPrintf ( color , "%s" , std :: string ( str , p ) . c_str ( ) ) ; |
| 6388: |
| 6389: const char ch = p [ 1 ] ; |
| 6390: = p + 2 ; |
6391: if/* if (ch == '@') {
ColoredPrintf(color, "@");
} else if (ch == 'D') {
color = GTestColor::kDefault;
} else if (ch == 'R') {
color = GTestColor::kRed;
} else if (ch == 'G') {
color = GTestColor::kGreen;
} else if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
} */ ch == '@' ) {/*
ColoredPrintf(color, "@");
*/ |
6392: ColoredPrintf/* ColoredPrintf(color, "@") */ ( color , "@" ) ; |
| 6393: } else if/* if (ch == 'D') {
color = GTestColor::kDefault;
} else if (ch == 'R') {
color = GTestColor::kRed;
} else if (ch == 'G') {
color = GTestColor::kGreen;
} else if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
} */ ch == 'D' ) {/*
color = GTestColor::kDefault;
*/ |
6394: color/* color = GTestColor::kDefault */ = GTestColor :: kDefault ; |
| 6395: } else if/* if (ch == 'R') {
color = GTestColor::kRed;
} else if (ch == 'G') {
color = GTestColor::kGreen;
} else if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
} */ ch == 'R' ) {/*
color = GTestColor::kRed;
*/ |
6396: color/* color = GTestColor::kRed */ = GTestColor :: kRed ; |
| 6397: } else if/* if (ch == 'G') {
color = GTestColor::kGreen;
} else if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
} */ ch == 'G' ) {/*
color = GTestColor::kGreen;
*/ |
6398: color/* color = GTestColor::kGreen */ = GTestColor :: kGreen ; |
| 6399: } else if/* if (ch == 'Y') {
color = GTestColor::kYellow;
} else {
--str;
} */ ch == 'Y' ) {/*
color = GTestColor::kYellow;
*/ |
6400: color/* color = GTestColor::kYellow */ = GTestColor :: kYellow ; |
| 6401: } else |
| 6402: str ; |
| 6403: } |
| 6404: } |
| 6405: } |
| 6406: |
| 6407: static const char kColorEncodedHelpMessage [ ] = |
| 6408: "This program contains tests written using " GTEST_NAME_ |
| 6409: ". You can use the\n" |
| 6410: "following command line flags to control its behavior:\n" |
| 6411: "\n" |
| 6412: "Test Selection:\n" |
| 6413: " @G--" GTEST_FLAG_PREFIX_ |
| 6414: "list_tests@D\n" |
| 6415: " List the names of all tests instead of running them. The name of\n" |
| 6416: " TEST(Foo, Bar) is \"Foo.Bar\".\n" |
| 6417: " @G--" GTEST_FLAG_PREFIX_ |
| 6418: "filter=@YPOSITIVE_PATTERNS" |
| 6419: "[@G-@YNEGATIVE_PATTERNS]@D\n" |
| 6420: " Run only the tests whose name matches one of the positive patterns " |
| 6421: "but\n" |
| 6422: " none of the negative patterns. '?' matches any single character; " |
| 6423: "'*'\n" |
| 6424: " matches any substring; ':' separates two patterns.\n" |
| 6425: " @G--" GTEST_FLAG_PREFIX_ |
| 6426: "also_run_disabled_tests@D\n" |
| 6427: " Run all disabled tests too.\n" |
| 6428: "\n" |
| 6429: "Test Execution:\n" |
| 6430: " @G--" GTEST_FLAG_PREFIX_ |
| 6431: "repeat=@Y[COUNT]@D\n" |
| 6432: " Run the tests repeatedly; use a negative count to repeat forever.\n" |
| 6433: " @G--" GTEST_FLAG_PREFIX_ |
| 6434: "shuffle@D\n" |
| 6435: " Randomize tests' orders on every iteration.\n" |
| 6436: " @G--" GTEST_FLAG_PREFIX_ |
| 6437: "random_seed=@Y[NUMBER]@D\n" |
| 6438: " Random number seed to use for shuffling test orders (between 1 and\n" |
| 6439: " 99999, or 0 to use a seed based on the current time).\n" |
| 6440: "\n" |
| 6441: "Test Output:\n" |
| 6442: " @G--" GTEST_FLAG_PREFIX_ |
| 6443: "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n" |
| 6444: " Enable/disable colored output. The default is @Gauto@D.\n" |
| 6445: " @G--" GTEST_FLAG_PREFIX_ |
| 6446: "brief=1@D\n" |
| 6447: " Only print test failures.\n" |
| 6448: " @G--" GTEST_FLAG_PREFIX_ |
| 6449: "print_time=0@D\n" |
| 6450: " Don't print the elapsed time of each test.\n" |
| 6451: " @G--" GTEST_FLAG_PREFIX_ |
| 6452: "output=@Y(@Gjson@Y|@Gxml@Y)[@G:@YDIRECTORY_PATH@G" GTEST_PATH_SEP_ |
| 6453: "@Y|@G:@YFILE_PATH]@D\n" |
| 6454: " Generate a JSON or XML report in the given directory or with the " |
| 6455: "given\n" |
| 6456: " file name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.\n" |
| 6457: # if GTEST_CAN_STREAM_RESULTS_ |
| 6458: " @G--" GTEST_FLAG_PREFIX_ |
| 6459: "stream_result_to=@YHOST@G:@YPORT@D\n" |
| 6460: " Stream test results to the given server.\n" |
| 6461: # endif |
| 6462: "\n" |
| 6463: "Assertion Behavior:\n" |
| 6464: # if GTEST_HAS_DEATH_TEST && ! GTEST_OS_WINDOWS |
| 6465: " @G--" GTEST_FLAG_PREFIX_ |
| 6466: "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n" |
| 6467: " Set the default death test style.\n" |
| 6468: # endif |
| 6469: " @G--" GTEST_FLAG_PREFIX_ |
| 6470: "break_on_failure@D\n" |
| 6471: " Turn assertion failures into debugger break-points.\n" |
| 6472: " @G--" GTEST_FLAG_PREFIX_ |
| 6473: "throw_on_failure@D\n" |
| 6474: " Turn assertion failures into C++ exceptions for use by an external\n" |
| 6475: " test framework.\n" |
| 6476: " @G--" GTEST_FLAG_PREFIX_ |
| 6477: "catch_exceptions=0@D\n" |
| 6478: " Do not report exceptions as test failures. Instead, allow them\n" |
| 6479: " to crash the program or throw a pop-up (on Windows).\n" |
| 6480: "\n" |
| 6481: "Except for @G--" GTEST_FLAG_PREFIX_ |
| 6482: "list_tests@D, you can alternatively set " |
| 6483: "the corresponding\n" |
| 6484: "environment variable of a flag (all letters in upper-case). For example, " |
| 6485: "to\n" |
| 6486: "disable colored text output, you can either specify " |
| 6487: "@G--" GTEST_FLAG_PREFIX_ |
| 6488: "color=no@D or set\n" |
| 6489: "the @G" GTEST_FLAG_PREFIX_UPPER_ |
| 6490: "COLOR@D environment variable to @Gno@D.\n" |
| 6491: "\n" |
| 6492: "For more information, please read the " GTEST_NAME_ |
| 6493: " documentation at\n" |
| 6494: "@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ |
| 6495: "\n" |
| 6496: "(not one in your own code or tests), please report it to\n" |
| 6497: "@G<" GTEST_DEV_EMAIL_ ">@D.\n" ; |
| 6498: |
| 6499: static bool ParseGoogleTestFlag ( const char * const arg ) { |
| 6500: return ParseBoolFlagtruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalse ( arg , kAlsoRunDisabledTestsFlag , |
| 6501: & GTEST_FLAG ( also_run_disabled_tests ) ) |
| 6502: ParseBoolFlag ( arg , kBreakOnFailureFlag , |
| 6503: & GTEST_FLAG ( break_on_failure ) ) |
| 6504: ParseBoolFlag ( arg , kCatchExceptionsFlag , |
| 6505: & GTEST_FLAG ( catch_exceptions ) ) |
| 6506: ParseStringFlag ( arg , kColorFlag , & GTEST_FLAG ( color ) ) |
| 6507: ParseStringFlag ( arg , kDeathTestStyleFlag , |
| 6508: & GTEST_FLAG ( death_test_style ) ) |
| 6509: ParseBoolFlag ( arg , kDeathTestUseFork , |
| 6510: & GTEST_FLAG ( death_test_use_fork ) ) |
| 6511: ParseBoolFlag ( arg , kFailFast , & GTEST_FLAG ( fail_fast ) ) |
| 6512: ParseStringFlag ( arg , kFilterFlag , & GTEST_FLAG ( filter ) ) |
| 6513: ParseStringFlag ( arg , kInternalRunDeathTestFlag , |
| 6514: & GTEST_FLAG ( internal_run_death_test ) ) |
| 6515: ParseBoolFlag ( arg , kListTestsFlag , & GTEST_FLAG ( list_tests ) ) |
| 6516: ParseStringFlag ( arg , kOutputFlag , & GTEST_FLAG ( output ) ) |
| 6517: ParseBoolFlag ( arg , kBriefFlag , & GTEST_FLAG ( brief ) ) |
| 6518: ParseBoolFlag ( arg , kPrintTimeFlag , & GTEST_FLAG ( print_time ) ) |
| 6519: ParseBoolFlag ( arg , kPrintUTF8Flag , & GTEST_FLAG ( print_utf8 ) ) |
| 6520: ParseInt32Flag ( arg , kRandomSeedFlag , & GTEST_FLAG ( random_seed ) ) |
| 6521: ParseInt32Flag ( arg , kRepeatFlag , & GTEST_FLAG ( repeat ) ) |
| 6522: ParseBoolFlag ( arg , kShuffleFlag , & GTEST_FLAG ( shuffle ) ) |
| 6523: ParseInt32Flag ( arg , kStackTraceDepthFlag , |
| 6524: & GTEST_FLAG ( stack_trace_depth ) ) |
| 6525: ParseStringFlag ( arg , kStreamResultToFlag , |
| 6526: & GTEST_FLAG ( stream_result_to ) ) |
| 6527: ParseBoolFlag ( arg , kThrowOnFailureFlag , & GTEST_FLAG ( throw_on_failure ) ) ; |
| 6528: } |
| 6529: |
| 6530: # if GTEST_USE_OWN_FLAGFILE_FLAG_ |
| 6531: static void LoadFlagsFromFile ( const std :: string & path ) {/*
FILE* flagfile = posix::FOpen(path.c_str(), "r");
if (!flagfile) {
GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile)
<< "\"";
}
std::string contents(ReadEntireFile(flagfile));
posix::FClose(flagfile);
std::vector<std::string> lines;
SplitString(contents, '\n', &lines);
for (size_t i = 0; i < lines.size(); ++i) {
if (lines[i].empty())
continue;
if (!ParseGoogleTestFlag(lines[i].c_str()))
g_help_flag = true;
}
*/ |
| 6532: FILE * flagfile = posix :: FOpen ( path . c_str ( ) , "r" ) ; |
6533: if/* if (!flagfile) {
GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile)
<< "\"";
} */ ! flagfile ) {/*
GTEST_LOG_(FATAL) << "Unable to open file \"" << GTEST_FLAG(flagfile)
<< "\"";
*/ |
| 6534: GTEST_LOG_ ( FATAL ) << "Unable to open file \"" << GTEST_FLAG ( flagfile ) |
| 6535: << "\"" ; |
| 6536: } |
| 6537: std :: string contents ( ReadEntireFile ( flagfile ) ) ; |
6538: posix/* posix::FClose(flagfile) */ :: FClose ( flagfile ) ; |
| 6539: std :: vector < std :: string > lines ; |
6540: SplitString/* SplitString(contents, '\n', &lines) */ ( contents , '\n' , & lines ) ; |
6541: for/* for (size_t i = 0; i < lines.size(); ++i) {
if (lines[i].empty())
continue;
if (!ParseGoogleTestFlag(lines[i].c_str()))
g_help_flag = true;
} */ ( size_t i = 0 ; i < lines . size ( ) ; ++ i ) {/*
if (lines[i].empty())
continue;
if (!ParseGoogleTestFlag(lines[i].c_str()))
g_help_flag = true;
*/ |
6542: if/* if (lines[i].empty())
continue */ lines [ i ] . empty ( ) ) |
| 6543: continue ; |
6544: if/* if (!ParseGoogleTestFlag(lines[i].c_str()))
g_help_flag = true */ (truefalse!!ParseGoogleTestFlag(lines[i].c_str()) ! ParseGoogleTestFlag ( lines [ i ] . c_str ( ) ) ) |
| 6545: g_help_flag = true ; |
| 6546: } |
| 6547: } |
| 6548: # endif |
| 6549: |
| 6550: |
| 6551: |
| 6552: |
| 6553: template < typename CharType > |
| 6554: void ParseGoogleTestFlagsOnlyImpl ( int * argc , CharType * * argv ) {/*
for (int i = 1; i < *argc; i++) {
const std::string arg_string = StreamableToString(argv[i]);
const char* const arg = arg_string.c_str();
using internal::ParseBoolFlag;
using internal::ParseInt32Flag;
using internal::ParseStringFlag;
bool remove_flag = false;
if (ParseGoogleTestFlag(arg)) {
remove_flag = true;
#if GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) {
LoadFlagsFromFile(GTEST_FLAG(flagfile));
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (arg_string == "--help" || arg_string == "-h" ||
arg_string == "-?" || arg_string == "/?" ||
HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
}
if (remove_flag) {
// Shift the remainder of the argv list left by one. Note
// that argv has (*argc + 1) elements, the last one always being
// NULL. The following loop moves the trailing NULL element as
// well.
for (int j = i; j != *argc; j++) {
argv[j] = argv[j + 1];
}
// Decrements the argument count.
(*argc)--;
// We also need to decrement the iterator as we just removed
// an element.
i--;
}
}
if (g_help_flag) {
// We print the help here instead of in RUN_ALL_TESTS(), as the
// latter may not be called at all if the user is using Google
// Test with another testing framework.
PrintColorEncoded(kColorEncodedHelpMessage);
}
*/ |
6555: for/* for (int i = 1; i < *argc; i++) {
const std::string arg_string = StreamableToString(argv[i]);
const char* const arg = arg_string.c_str();
using internal::ParseBoolFlag;
using internal::ParseInt32Flag;
using internal::ParseStringFlag;
bool remove_flag = false;
if (ParseGoogleTestFlag(arg)) {
remove_flag = true;
#if GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) {
LoadFlagsFromFile(GTEST_FLAG(flagfile));
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (arg_string == "--help" || arg_string == "-h" ||
arg_string == "-?" || arg_string == "/?" ||
HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
}
if (remove_flag) {
// Shift the remainder of the argv list left by one. Note
// that argv has (*argc + 1) elements, the last one always being
// NULL. The following loop moves the trailing NULL element as
// well.
for (int j = i; j != *argc; j++) {
argv[j] = argv[j + 1];
}
// Decrements the argument count.
(*argc)--;
// We also need to decrement the iterator as we just removed
// an element.
i--;
}
} */ ( int i = 1 ; i < * argc ; i ++ ) {/*
const std::string arg_string = StreamableToString(argv[i]);
const char* const arg = arg_string.c_str();
using internal::ParseBoolFlag;
using internal::ParseInt32Flag;
using internal::ParseStringFlag;
bool remove_flag = false;
if (ParseGoogleTestFlag(arg)) {
remove_flag = true;
#if GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) {
LoadFlagsFromFile(GTEST_FLAG(flagfile));
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (arg_string == "--help" || arg_string == "-h" ||
arg_string == "-?" || arg_string == "/?" ||
HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
}
if (remove_flag) {
// Shift the remainder of the argv list left by one. Note
// that argv has (*argc + 1) elements, the last one always being
// NULL. The following loop moves the trailing NULL element as
// well.
for (int j = i; j != *argc; j++) {
argv[j] = argv[j + 1];
}
// Decrements the argument count.
(*argc)--;
// We also need to decrement the iterator as we just removed
// an element.
i--;
}
*/ |
| 6556: const std :: string arg_string = StreamableToString ( argv [ i ] ) ; |
| 6557: const char * const arg = arg_string . c_str ( ) ; |
| 6558: |
| 6559: using internal :: ParseBoolFlag ; |
| 6560: using internal :: ParseInt32Flag ; |
| 6561: using internal :: ParseStringFlag ; |
| 6562: |
| 6563: bool remove_flag = false ; |
6564: if/* if (ParseGoogleTestFlag(arg)) {
remove_flag = true;
#if GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) {
LoadFlagsFromFile(GTEST_FLAG(flagfile));
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (arg_string == "--help" || arg_string == "-h" ||
arg_string == "-?" || arg_string == "/?" ||
HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
} */ ParseGoogleTestFlag ( arg ) ) {/*
remove_flag = true;
#if GTEST_USE_OWN_FLAGFILE_FLAG_
*/ |
6565: remove_flag/* remove_flag = true */ = true ; |
| 6566: # if GTEST_USE_OWN_FLAGFILE_FLAG_ |
| 6567: } else if/* if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) {
LoadFlagsFromFile(GTEST_FLAG(flagfile));
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (arg_string == "--help" || arg_string == "-h" ||
arg_string == "-?" || arg_string == "/?" ||
HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
} */ ParseStringFlag ( arg , kFlagfileFlag , & GTEST_FLAG ( flagfile ) ) ) {/*
LoadFlagsFromFile(GTEST_FLAG(flagfile));
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
*/ |
6568: LoadFlagsFromFile/* LoadFlagsFromFile(GTEST_FLAG(flagfile)) */ ( GTEST_FLAG ( flagfile ) ) ; |
6569: remove_flag/* remove_flag = true */ = true ; |
| 6570: # endif |
| 6571: } else if/* if (arg_string == "--help" || arg_string == "-h" ||
arg_string == "-?" || arg_string == "/?" ||
HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
} */ (truefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalsetruefalse arg_string == "--help" == "-h" |
| 6572: == "-?" == "/?" |
| 6573: HasGoogleTestFlagPrefix ( arg ) ) {/*
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
*/ |
| 6574: |
| 6575: |
6576: g_help_flag/* g_help_flag = true */ = true ; |
| 6577: } |
| 6578: |
6579: if/* if (remove_flag) {
// Shift the remainder of the argv list left by one. Note
// that argv has (*argc + 1) elements, the last one always being
// NULL. The following loop moves the trailing NULL element as
// well.
for (int j = i; j != *argc; j++) {
argv[j] = argv[j + 1];
}
// Decrements the argument count.
(*argc)--;
// We also need to decrement the iterator as we just removed
// an element.
i--;
} */ remove_flag ) {/*
// Shift the remainder of the argv list left by one. Note
// that argv has (*argc + 1) elements, the last one always being
// NULL. The following loop moves the trailing NULL element as
// well.
for (int j = i; j != *argc; j++) {
argv[j] = argv[j + 1];
}
// Decrements the argument count.
(*argc)--;
// We also need to decrement the iterator as we just removed
// an element.
i--;
*/ |
| 6580: |
| 6581: |
| 6582: |
| 6583: |
6584: for/* for (int j = i; j != *argc; j++) {
argv[j] = argv[j + 1];
} */ ( int j = i ; j != * argc ; j ++ ) {/*
argv[j] = argv[j + 1];
*/ |
6585: argv/* argv[j] = argv[j + 1] */ [ j ] = argv [ j + 1 ] ; |
| 6586: } |
| 6587: |
| 6588: |
| 6589: * argc ) -- ; |
| 6590: |
| 6591: |
| 6592: |
| 6593: -- ; |
| 6594: } |
| 6595: } |
| 6596: |
6597: if/* if (g_help_flag) {
// We print the help here instead of in RUN_ALL_TESTS(), as the
// latter may not be called at all if the user is using Google
// Test with another testing framework.
PrintColorEncoded(kColorEncodedHelpMessage);
} */ g_help_flag ) {/*
// We print the help here instead of in RUN_ALL_TESTS(), as the
// latter may not be called at all if the user is using Google
// Test with another testing framework.
PrintColorEncoded(kColorEncodedHelpMessage);
*/ |
| 6598: |
| 6599: |
| 6600: |
6601: PrintColorEncoded/* PrintColorEncoded(kColorEncodedHelpMessage) */ ( kColorEncodedHelpMessage ) ; |
| 6602: } |
| 6603: } |
| 6604: |
| 6605: |
| 6606: |
| 6607: void ParseGoogleTestFlagsOnly ( int * argc , char * * argv ) {/*
ParseGoogleTestFlagsOnlyImpl(argc, argv);
// Fix the value of *_NSGetArgc() on macOS, but if and only if
// *_NSGetArgv() == argv
// Only applicable to char** version of argv
#if GTEST_OS_MAC
#ifndef GTEST_OS_IOS
if (*_NSGetArgv() == argv) {
*_NSGetArgc() = *argc;
}
#endif
#endif
*/ |
6608: ParseGoogleTestFlagsOnlyImpl/* ParseGoogleTestFlagsOnlyImpl(argc, argv) */ ( argc , argv ) ; |
| 6609: |
| 6610: |
| 6611: |
| 6612: |
| 6613: # if GTEST_OS_MAC |
| 6614: # ifndef GTEST_OS_IOS |
| 6615: if ( * _NSGetArgv ( ) == argv ) { |
| 6616: * _NSGetArgc ( ) = * argc ; |
| 6617: } |
| 6618: # endif |
| 6619: # endif |
| 6620: } |
| 6621: void ParseGoogleTestFlagsOnly ( int * argc , wchar_t * * argv ) {/*
ParseGoogleTestFlagsOnlyImpl(argc, argv);
*/ |
6622: ParseGoogleTestFlagsOnlyImpl/* ParseGoogleTestFlagsOnlyImpl(argc, argv) */ ( argc , argv ) ; |
| 6623: } |
| 6624: |
| 6625: |
| 6626: |
| 6627: |
| 6628: |
| 6629: template < typename CharType > |
| 6630: void InitGoogleTestImpl ( int * argc , CharType * * argv ) {/*
// We don't want to run the initialization code twice.
if (GTestIsInitialized()) return;
if (*argc <= 0) return;
g_argvs.clear();
for (int i = 0; i != *argc; i++) {
g_argvs.push_back(StreamableToString(argv[i]));
}
#if GTEST_HAS_ABSL
absl::InitializeSymbolizer(g_argvs[0].c_str());
#endif // GTEST_HAS_ABSL
ParseGoogleTestFlagsOnly(argc, argv);
GetUnitTestImpl()->PostFlagParsingInit();
*/ |
| 6631: |
6632: if/* if (GTestIsInitialized()) return */ GTestIsInitialized ( ) ) ; |
| 6633: |
6634: if/* if (*argc <= 0) return */ * argc <= 0 ) ; |
| 6635: |
6636: g_argvs/* g_argvs.clear() */ . clear ( ) ; |
6637: for/* for (int i = 0; i != *argc; i++) {
g_argvs.push_back(StreamableToString(argv[i]));
} */ ( int i = 0 ; i != * argc ; i ++ ) {/*
g_argvs.push_back(StreamableToString(argv[i]));
*/ |
6638: g_argvs/* g_argvs.push_back(StreamableToString(argv[i])) */ . push_back ( StreamableToString ( argv [ i ] ) ) ; |
| 6639: } |
| 6640: |
| 6641: # if GTEST_HAS_ABSL |
| 6642: absl :: InitializeSymbolizer ( g_argvs [ 0 ] . c_str ( ) ) ; |
| 6643: # endif |
| 6644: |
6645: ParseGoogleTestFlagsOnly/* ParseGoogleTestFlagsOnly(argc, argv) */ ( argc , argv ) ; |
6646: GetUnitTestImpl/* GetUnitTestImpl()->PostFlagParsingInit() */ ( ) -> PostFlagParsingInit ( ) ; |
| 6647: } |
| 6648: |
| 6649: } |
| 6650: |
| 6651: |
| 6652: |
| 6653: |
| 6654: |
| 6655: |
| 6656: |
| 6657: |
| 6658: |
| 6659: |
| 6660: void InitGoogleTest ( int * argc , char * * argv ) {/*
#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);
#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
internal::InitGoogleTestImpl(argc, argv);
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
*/ |
| 6661: # if defined ( GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_ ) |
| 6662: GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_ ( argc , argv ) ; |
| 6663: # else |
6664: internal/* internal::InitGoogleTestImpl(argc, argv) */ :: InitGoogleTestImpl ( argc , argv ) ; |
| 6665: # endif |
| 6666: } |
| 6667: |
| 6668: |
| 6669: |
| 6670: void InitGoogleTest ( int * argc , wchar_t * * argv ) {/*
#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);
#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
internal::InitGoogleTestImpl(argc, argv);
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
*/ |
| 6671: # if defined ( GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_ ) |
| 6672: GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_ ( argc , argv ) ; |
| 6673: # else |
6674: internal/* internal::InitGoogleTestImpl(argc, argv) */ :: InitGoogleTestImpl ( argc , argv ) ; |
| 6675: # endif |
| 6676: } |
| 6677: |
| 6678: |
| 6679: |
| 6680: void InitGoogleTest ( ) {/*
// Since Arduino doesn't have a command line, fake out the argc/argv arguments
int argc = 1;
const auto arg0 = "dummy";
char* argv0 = const_cast<char*>(arg0);
char** argv = &argv0;
#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(&argc, argv);
#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
internal::InitGoogleTestImpl(&argc, argv);
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
*/ |
| 6681: |
| 6682: int argc = 1 ; |
| 6683: const auto arg0 = "dummy" ; |
| 6684: char * argv0 = const_cast < char * > ( arg0 ) ; |
| 6685: char * * argv = & argv0 ; |
| 6686: |
| 6687: # if defined ( GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_ ) |
| 6688: GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_ ( & argc , argv ) ; |
| 6689: # else |
6690: internal/* internal::InitGoogleTestImpl(&argc, argv) */ :: InitGoogleTestImpl ( & argc , argv ) ; |
| 6691: # endif |
| 6692: } |
| 6693: |
| 6694: std :: string TempDir ( ) { |
| 6695: # if defined ( GTEST_CUSTOM_TEMPDIR_FUNCTION_ ) |
| 6696: return GTEST_CUSTOM_TEMPDIR_FUNCTION_ ( ) ; |
| 6697: # elif GTEST_OS_WINDOWS_MOBILE |
| 6698: return "\\temp\\" ; |
| 6699: # elif GTEST_OS_WINDOWS |
| 6700: const char * temp_dir = internal :: posix :: GetEnv ( "TEMP" ) ; |
| 6701: if ( temp_dir == nullptr || temp_dir [ 0 ] == '\0' ) { |
| 6702: return "\\temp\\" ; |
| 6703: } else if ( temp_dir [ strlen ( temp_dir ) - 1 ] == '\\' ) { |
| 6704: return temp_dir ; |
| 6705: } else { |
| 6706: return std :: string ( temp_dir ) + "\\" ; |
| 6707: } |
| 6708: # elif GTEST_OS_LINUX_ANDROID |
| 6709: const char * temp_dir = internal :: posix :: GetEnv ( "TEST_TMPDIR" ) ; |
| 6710: if ( temp_dir == nullptr || temp_dir [ 0 ] == '\0' ) { |
| 6711: return "/data/local/tmp/" ; |
| 6712: } else { |
| 6713: return temp_dir ; |
| 6714: } |
| 6715: # elif GTEST_OS_LINUX |
| 6716: const char * temp_dir = internal :: posix :: GetEnv ( "TEST_TMPDIR" ) ; |
| 6717: if (truefalsetruefalsetruefalse temp_dir == nullptr [ 0 ] == '\0' ) { |
| 6718: return "/tmp/" ; |
| 6719: } else { |
| 6720: return temp_dir ; |
| 6721: } |
| 6722: # else |
| 6723: return "/tmp/" ; |
| 6724: # endif |
| 6725: } |
| 6726: |
| 6727: |
| 6728: |
| 6729: |
| 6730: |
| 6731: void ScopedTrace :: PushTrace ( const char * file , int line , std :: string message ) {/*
internal::TraceInfo trace;
trace.file = file;
trace.line = line;
trace.message.swap(message);
UnitTest::GetInstance()->PushGTestTrace(trace);
*/ |
| 6732: internal :: TraceInfo trace ; |
6733: trace/* trace.file = file */ . file = file ; |
6734: trace/* trace.line = line */ . line = line ; |
6735: trace/* trace.message.swap(message) */ . message . swap ( message ) ; |
| 6736: |
6737: UnitTest/* UnitTest::GetInstance()->PushGTestTrace(trace) */ :: GetInstance ( ) -> PushGTestTrace ( trace ) ; |
| 6738: } |
| 6739: |
| 6740: |
| 6741: ScopedTrace :: ~ ScopedTrace ( ) |
| 6742: GTEST_LOCK_EXCLUDED_ ( & UnitTest :: mutex_ ) {/*
UnitTest::GetInstance()->PopGTestTrace();
*/ |
| 6743: UnitTest :: GetInstance ( ) -> PopGTestTrace ( ) ; |
| 6744: } |
| 6745: |
| 6746: } |